[#394253] gtk2 install error — CC Chen <lists@...>
Hi,
[#394259] return_bang 1.1 Released — Eric Hodel <drbrain@...7.net>
home :: https://github.com/drbrain/return_bang
[#394281] Can someone throw me a bone — Bob Baird <lists@...>
Hi all,
[#394290] openSUSE fan? — Jos Poortvliet <jos@...>
Heya Ruby and Rails hackers!
[#394310] fibonacci and defining variables — "Christopher D." <lists@...>
I was doing an example on Fibonacci sequences and this confused me a
[#394311] using hash as database? Secure databases with ruby? — ruby rocks <lists@...>
I am new to programming and am learning ruby as my first language. I
On Tue, Apr 3, 2012 at 10:30 AM, ruby rocks <lists@ruby-forum.com> wrote:
Hassan Schroeder wrote in post #1054862:
Florian Gilcher wrote in post #1054875:
On Tue, Apr 3, 2012 at 1:14 PM, ruby rocks <lists@ruby-forum.com> wrote:
Hassan Schroeder wrote in post #1054884:
[#394324] RegEx for a string between two symbols — "Christopher D." <lists@...>
I'm looking to build a dictionary application. One part that I am having
Hi,
Jan E. wrote in post #1054912:
[#394334] Ruby on Windows... — Hal Fulton <rubyhacker@...>
It's been a long time since I did anything on Windows... I'm now
[#394369] Terminated Object Error. Help Needed — Tridib Bandopadhyay <lists@...>
Here is my sample code:-
[#394375] Call for comments - Structure — Hal Fulton <rubyhacker@...>
Greetings, fellow Rubyists...
Hal Fulton wrote in post #1055070:
W dniu 5 kwietnia 2012 14:21 u=C5=BCytkownik Robert Klemme
On Thu, Apr 5, 2012 at 4:33 PM, Bartosz Dziewo=F1ski <matma.rex@gmail.com> =
2012/4/5 Robert Klemme <shortcutter@googlemail.com>
On Thu, Apr 5, 2012 at 5:18 PM, Hal Fulton <rubyhacker@gmail.com> wrote:
On Thu, Apr 5, 2012 at 5:00 PM, Robert Klemme <shortcutter@googlemail.com>wrote:
[#394381] For beginners: Rubeque.com, interactive Ruby coding practice — "S. W." <lists@...>
I stumbled across this site recently and found it very useful for
[#394384] Not a Memory Leak but Stale Objects - clears with GC.start — Tom Moulton <lists@...>
I have a long running process.
[#394386] Want to get exact match from sentence — Lucky Nl <lists@...>
SGkgZnJpZW5kcywKCiAgIEkgbmVlZCB0byBzZWFyY2ggZXhhY3QgbWF0Y2gg
[#394390] Design pattern question — James French <James.French@...>
Hi group,
James French wrote in post #1055131:
DQoNCi0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQpGcm9tOiBSb2JlcnQgS2xlbW1lIFttYWls
On Thu, Apr 5, 2012 at 4:25 PM, James French
W dniu 5 kwietnia 2012 21:27 u=C5=BCytkownik Steve Klabnik
> Abstract classes are sometimes useful (although rarely). For example,
[#394425] Google Group Mirror Broken — Thomas Sawyer <lists@...>
Looks like, sometime in February, posts started to go missing from the
[#394435] Add a GUI to your Ruby Script — "Eric C." <lists@...>
Hi:
[#394440] Advise on learning Ruby — "Taz798 U." <lists@...>
Hello,
[#394457] Best way of implementing controllers for m:n model relation (Car->Parts) — Thomas Tschofenig <lists@...>
Hello,
[#394469] Group Status — Intransition <transfire@...>
The Google Group mirror now appears to be 100% dead.
-----BEGIN PGP SIGNED MESSAGE-----
[#394471] How to pull out specific part of a variable and set to another variable? — "Charlie B." <lists@...>
I have a variable that is a long string. The variable looks like this:
Here's a possible approach
2012/4/9 Iachetti Federico Mart=EDn <iachetti.federico@gmail.com>:
[#394492] New to Ruby, tutorial gives wrong example. — Roger McDonald <lists@...>
I am just starting with Ruby with intention to learn and perhaps use it
You maxe a spelling mistake in the method name initialize.
i just realized that i made (maxe) a spelling mistake too ;)
Wow, thank you all for replying, it is really appreciated.
[#394499] need to match words from setence — Lucky Nl <lists@...>
Hi friends,
Hmm include method will match substring too.This is not i want .I want
[#394519] Copy all files in a directory — "Charlie B." <lists@...>
Still new to Ruby and feel silly having to ask such a simple question,
[#394533] A Beginner's Question about Metaprogramming — Phil Stone <lists@...>
Hey guys, have a question about Ruby programming and found this forum
Thanks for the help!
[#394538] less absolutely horrible way to make sure array 1 only contains elements from array 2? — ruby ismyname <lists@...>
@selections = []
[#394565] Possible to spawn windows explorer to select files/directories? — "Charlie B." <lists@...>
I have a script that I would like to be able to spawn a windows shell so
[#394576] Regular expression help — Alex Sweps <lists@...>
Hello all
[#394580] conditionally use greater than or less than — phil rosenstein <lists@...>
what is the best way to do this in ruby?
[#394587] ruby v.1.8.6. Expand array class, make combinations — Ronnie Aa <lists@...>
Hi,
Hi Ralf,
[#394592] Upgrading to Ruby 1.9 - Should I? Is it painful? — Oren Shani <lists@...>
Hi All,
Oren Shani wrote in post #1056125:
W dniu 16 kwietnia 2012 22:05 u=C5=BCytkownik Brian Candler
[#394604] request for feature: nested methods should be private on nesting method — botp <botpena@...>
Hi ,
[#394616] How to test if array element exists? — Soul Surf <lists@...>
I'm new to Ruby and just want to test if an array element exists. Here's
Hi,
[#394631] Arguments with Funktion — "roboter Y." <lists@...>
i want a ruby program, is have 2 Arguments(a,b) ,which output the Prime
[#394641] GC on two C extension objects — Mike Owens <mikeowens@...>
I am running into a problem with to C extension objects and I'm not sure
[#394642] how to avoid escaping special chars after backslah in string — Lucky Nl <lists@...>
Hi friends,
so what's your ideal syntax here?
Roger Pack wrote in post #1056378:
On Fri, Apr 13, 2012 at 8:21 PM, Lucky Nl <lists@ruby-forum.com> wrote:
On 04/13/2012 09:01 PM, Roger Pack wrote:
" \\imp ".match(/
[#394643] unable to do "down" range? — Roger Pack <lists@...>
Hello.
Hi,
Roger and Jan,
[#394658] Why doesn't Fixnum#to_d exist? — Mark Campbell <nitrodist@...>
http://stdlib.rubyonrails.org/libdoc/bigdecimal/rdoc/index.html
It does exist, but it's in a separate file - bigdecimal/util or utils,
Yes, that file has the String#to_d, Float#to_d and Rational#to_d.
>irb
On Sat, Apr 14, 2012 at 07:23:34AM +0900, Mark Campbell wrote:
On Sat, Apr 14, 2012 at 11:45 AM, Chad Perrin <code@apotheon.net> wrote:
[#394675] Operator overloading of the subscript operator — Ralph Shnelvar <ralphs@...32.com>
I understand that operators (e.g. +, -, *, []) are nothing more than method names so that
Hi,
Jan,
Ralph Shnelvar wrote in post #1056506:
On Sat, Apr 14, 2012 at 10:48 AM, Ralph Shnelvar <ralphs@dos32.com> wrote:
W dniu 15 kwietnia 2012 18:41 u=C5=BCytkownik Eric Christopherson
On Sat, Apr 14, 2012 at 5:03 PM, Jan E. <lists@ruby-forum.com> wrote:
[#394698] Great Ruby Apps/Libraries — Trans <transfire@...>
Other then Rails, what do you think the greatest Ruby app/library/gem is?
[#394713] Problem With Ruby.. — "Tucketdog J." <lists@...>
Specs: XCode 4.3.2, Mac OS X 10.7.3, RVM 1.12.3 (stable).
[#394717] insert text after line "whatever" — fox foxmaster <lists@...>
Hi all,
[#394732] C extensions: disable GC for a Ruby object and enable GC later for it — Iñaki Baz Castillo <ibc@...>
Hi, I do know this is very commented subject but I don't understand it clea=
On Mon, Apr 16, 2012 at 9:31 PM, I=C3=B1aki Baz Castillo <ibc@aliax.net> wr=
[#394751] Does the ruby ECC binding not include ec_point_mul? — roobie doo <lists@...>
It doesn't appear to after looking at the documentation, but I want to
[#394753] GVL lock and unlock — Iñaki Baz Castillo <ibc@...>
Hi, I'm coding a Ruby wrapper for libuv (the event-driven library used
On Tue, Apr 17, 2012 at 3:15 AM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
[#394766] A current version of Why's (Poignant) Guide to Ruby as PDF? — Joshua Muheim <lists@...>
Hey guys
[#394767] Capital Cyrillic letter in Ruby class name (UTF-8) — Vladimir Kerimov <lists@...>
Hi matz,
Here =D0=94=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82 is only a local var=
It could be funny, but it is make us use method at the place where we
[#394788] extconf.rb and checking for C++ headers — "Darryl L. Pierce" <mcpierce@...>
I'm extending our project [1] with some native extensions. Our code is
in 1.8 you need to add
[#394789] I am in ruby GUI toolkit hell — roobie doo <lists@...>
I have ruby installed, 1.9.3
[#394797] C extension: How to get a block passed to a method? — Iñaki Baz Castillo <ibc@...>
Hi, let's imagine the following Ruby code:
[#394803] Why must I know whether I extend a class or a module? — Marc Heiler <lists@...>
Hi.
On Wednesday, April 18, 2012 1:13:17 PM UTC-4, Marc Heiler wrote:
W dniu 19 kwietnia 2012 07:59 u=C5=BCytkownik Intransition
On Thursday, April 19, 2012 1:18:05 PM UTC-4, Bartosz Dziewo=C5=84ski wrote=
On 20 April 2012 13:53, Intransition <transfire@gmail.com> wrote:
On 21/04/2012, Intransition <transfire@gmail.com> wrote:
[#394812] Converting CSV — cristian cristian <lists@...>
Hello all!
Well, parsing the file and processing its content is certainly more
Jan E. wrote in post #1057244:
[#394828] Breaking large Ruby script into multiple files — Thomas Luedeke <lists@...>
On large Fortran projects, I'm accustomed to breaking them up into
[#394834] Which graphical/gui library is used for ruby? — gmspro gmspro <lists@...>
Is it opengl?
[#394838] When are numbers NOT Magic? Example. — Greg Willits <lists@...>
A risky and lengthy post, I'm hoping you'll indulge me on. Stack
[#394851] Berlin calling. — Marco Vismara <lists@...>
Hello everybody,
[#394853] How can i make the colorful font with black background for puts? — gmspro gmspro <lists@...>
puts 'Hello World."
How can i set the text color to light green? Not the 32 only.
[#394865] finding duplicates in an array and its index number — newto ruby <lists@...>
Hi,
[#394897] Google Group is Back — Intransition <transfire@...>
Well, like some sort of psychotic girlfriend, the Ruby-Talk Google Group is
[#394911] mruby - More info? — "Aaron D. Gifford" <astounding@...>
Where can I find more info. about mruby?
[#394923] What does '||=' mean? — Soichi Ishida <lists@...>
Well, as stated in the subject, what does '||=' mean?
[#394947] Why openssl on windows produces error but not on centos to read pkcs12 — Nauman Thanvi <lists@...>
Hi,
On Sun, Apr 22, 2012 at 9:35 AM, Nauman Thanvi <lists@ruby-forum.com> wrote:
Nauman Thanvi wrote in post #1057798:
[#394964] To developers of Ruby: Feeble documentation - weakness of Ruby and the Ruby on Rails (2nd edition) — Sergey Ezhov <lists@...>
RGlyZWN0bHkgSSBhcG9sb2dpemUgZm9yIG15IEVuZ2xpc2ggLSBJIHVzZWQg
I think you are a bit confused.
On Mon, Apr 23, 2012 at 5:11 AM, Brian Candler <lists@ruby-forum.com> wrote:
On Mon, Apr 23, 2012 at 9:17 PM, Ryan Davis <ryand-ruby@zenspider.com>wrote:
http://api.rubyonrails.org/ - disgusting documentation! There are no
[#394969] gem-packed script with DATA section does not work — Wybo Dekker <wybo@...4all.nl>
The attached minimal gem contains a script that reads "Hello World!"
Please can some one show me how to stop getting emails from
DATA points to the contents after the __END__ directive of the executable
On 2012-04-23 11:39, Xavier Noria wrote:
Ryan Davis писал 23.04.2012 22:58:
On 2012-04-23 22:57, Peter Zotov wrote:
I you don't need the BEGIN block nor constants, I think you could just use s=
On 2012-04-24 10:53, Xavier Noria wrote:
On Tue, Apr 24, 2012 at 11:01 AM, Wybo Dekker <wybo@xs4all.nl> wrote:
On 2012-04-24 11:08, Robert Klemme wrote:
On Tue, Apr 24, 2012 at 2:59 PM, Wybo Dekker <wybo@xs4all.nl> wrote:
[#394979] Join this code reading study group - already 20+ members — Adam Akhtar <lists@...>
If you're like me you want to get into the habit of reading source code
Ryan Davis wrote in post #1058025:
[#395011] problem with SystemStackError — Ralf Mueller <ralf.mueller@...>
Hi!
[#395014] New to Ruby, need install advice — "Rohit S." <lists@...>
I'm hoping I can get some advice on Ruby installs, as I sit a bit
[#395024] -BEGINNERS- Where do I Start? — "Thought M." <lists@...>
Hello World....... I am very new to code but have been glancing at it
[#395035] if if if statment — fox foxmaster <lists@...>
Hi all,
Hi I will attache the code since it gets format when I paste in paste
[#395055] matching substrings — Clay Tzoucalis <lists@...>
I need a little help with an assignment. Following is the code I am
I understand that. I am looking more for where to start,in attempt to
[#395063] Method Missing as Filter — "Christopher D." <lists@...>
Let's say I have a model called User. User has two attributes or table
On Wed, Apr 25, 2012 at 4:13 PM, Christopher D. <lists@ruby-forum.com> wrote:
[#395072] A question of style — Michel Demazure <lists@...>
When you write something like
[#395084] net::smtp carriage returns — "Tim L." <lists@...>
I'm new to ruby and trying to build a script that logs into a cisco pix
[#395085] Wrappng up my Text Game! Need Help! — Jared Hobbs <lists@...>
Hi, everyone. This is my first post!
Hmmm, you guys got any other suggestions that could handle user input?
Okay guys, again, I thank you for helping me!
[#395090] running a command line argument from rudy — "Christopher D." <lists@...>
Straight up. I have to use windows @ work but I still require some
On Thu, Apr 26, 2012 at 1:07 PM, Christopher D. <lists@ruby-forum.com> wrote:
Martin DeMello wrote in post #1058543:
[#395099] ruby/shoes GUI - sqlite, how to isert a variable key in table? — "Danilo L." <lists@...>
Hello, I am struggling to insert a variable into a table, for example:
Hi Danilo, How are you enjoying shoooes?
From what I've read[1], sqlite will coerce values into the declared
Michel wrote in post #1058590:
On Fri, Apr 27, 2012 at 9:35 AM, Danilo L. <lists@ruby-forum.com> wrote:
[#395113] why does this return 255 bits instead of 256 (and general bit byte hex string array crypt mayhem :P) — instance_variable ok <lists@...>
So I am doing something that requires me to manipulate things on the bit
why does a 32 character long string have a length (and bytesize) of 64
Remember, when you convert an integer to a string (#to_s) that leading
[#395126] Global variable for spaces per tab? — Intransition <transfire@...>
Is there any global variable in Ruby for specifying how tabs ("\t") should
On Sat, Apr 28, 2012 at 05:22:47AM +0900, Ryan Davis wrote:
[#395151] list local_variables in a def by means of a method — Ronnie Aa <lists@...>
Hello,
You can't. The "listvar" method has a different scope than "one" or
[#395161] What is the meaning of rb_thread_interrupted() ? — Iñaki Baz Castillo <ibc@...>
Hi, I'm coding a Ruby C extension and would like to know the meaning
I単aki Baz Castillo <ibc@aliax.net> wrote:
Eric Wong писал 29.04.2012 12:02:
Peter Zotov <whitequark@whitequark.org> wrote:
[#395178] I need some advice for a project I am working on — Joe Dirt <lists@...>
Hi,
[#395193] delete character from array — Ok Ok <lists@...>
Here is my question...
Yes that was exactly it. I have one more question maybe you can help me
This is a little blunt, but may be what you need:
Chris Morris wrote in post #1058975:
On Mon, Apr 30, 2012 at 7:11 PM, Brian Candler <lists@ruby-forum.com> wrote:
Robert Klemme wrote in post #1059013:
[#395204] Getting the associated exception instance after using rb_protect() — Iñaki Baz Castillo <ibc@...>
Hi, by using rb_protect() I can get an integer "exception" which I can
2012/4/30 I=F1aki Baz Castillo <ibc@aliax.net>:
2012/4/30 Martin Bo=C3=9Flet <martin.bosslet@googlemail.com>:
[#395210] Writing a file to txt, how can I put a new line? — "Christopher D." <lists@...>
I would like to create an error log for a application I have made. Here
You might want to look at puts. Or maybe one of the logging libraries that
Re: Call for comments - Structure
On Fri, Apr 6, 2012 at 12:17 AM, Hal Fulton <rubyhacker@gmail.com> wrote:
> On Thu, Apr 5, 2012 at 5:00 PM, Robert Klemme <shortcutter@googlemail.com=
>
> wrote:
>>
>> On Thu, Apr 5, 2012 at 5:18 PM, Hal Fulton <rubyhacker@gmail.com> wrote:
>> > 2012/4/5 Robert Klemme <shortcutter@googlemail.com>That I don't
>> > understand, maybe that's the reason for the previous
>> discussion: for me it is fairly easy and straightforward
>>
>> Counter =3D Struct.new :value do
>> =A0def incr(x =3D 1)
>> =A0 =A0self.value +=3D x
>> =A0end
>>
>> =A0alias to_i value
>> end
>>
>> I find that neither difficult nor impossible. =A0What did you have in mi=
nd?
>
>
> You are correct, of course. But it feels a little clumsy to me not to hav=
e
> direct access to the instance variables. That is purely subjective, and
> many will disagree with me.
OK, understood. I thought I might have missed something.
> What about the automated conversion of a hash to an object with accessors=
?
> Note that from_hash will handle one level and parse_hash will proceed
> recursively.
Well, but
irb(main):020:0> o=3DStructure.parse_hash(a:{:b=3D>:c})
ArgumentError: wrong number of arguments (2 for 1)
from /home/robert/projects/Hal9000-Structure-9f96182/structure.rb:30:in
`parse_hash'
from /home/robert/projects/Hal9000-Structure-9f96182/structure.rb:38:in
`block in parse_hash'
from /home/robert/projects/Hal9000-Structure-9f96182/structure.rb:34:in `e=
ach'
from /home/robert/projects/Hal9000-Structure-9f96182/structure.rb:34:in
`parse_hash'
from (irb):20
from /usr/local/bin/irb19:12:in `<main>'
:-)
> Am I the only one who likes obj.foo.bar better than obj['foo']['bar'] ?
Probably not. :-)
> I have been exposed to a lot of JSON in the last week...=A0 ;)
Ah, I see. First thing which stroke me odd was that Structure.new
might actually return an instance or a class. I find that bad for a
public interface because this is bound to cause confusion.
In the implementation I would replace "Structure." in method
definitions with "self." and throw it out completely inside methods to
reduce redundancy. Also, I am not sure whether it is good to cling to
a lot of state via all these closures created for define_method calls.
I tried to come up with a systematic list of what you want to do in
terms of input variants because I needed that for me to better
understand the matter. This is what I cam up with:
1. modifiability
a) fixed set of members
b) members can be added on the fly
2. values
a) not provided
b) provided in a Hash
3. recursive conversion from Hash (for 2b only)
a) no
b) yes
Conclusions:
It occurred to me that with 1a the list of members is conceptually a
property of the class, while in 1b it is a property of each instance.
From that it followed to me that it does not make sense to generate
classes for 1b. Thus you can define a replacement class for
OpenStruct and be done (either replacing the original, augmenting it
or having your own - I'd do the latter). Consequently there would be
no class factory method for that case - at most an instance factory
method.
So, class generation only makes sense for 1a. If we have 1a2b one
must decide what to do with the values. To keep the interface
consistent (my remark above) it seems most natural to me to use them
as default values for every created instance and not as values for a
single created instance which is immediately returned.
Now, in that case would 1a2b3b make sense? Or put differently: what
happens to recursive Hashes if we pass one? Since we must use keys of
the top level Hash to define members of the newly generated class, we
could either define more classes for nested Hashes or just use them as
is as default values. I tend to just use them as is because creating
a whole bunch of classes from a single factory method does not feel
right because the user does not have a chance to get hold of them.
(They would need to be referenced from the top level class so it could
construct instances properly). So I would leave out 1a2b3b
completely.
Implementation strategy:
My guiding rule is usually: use as few meta programming as possible.
Let's see how far we can get with that. The open case (1b) is done
already. Now for the closed case (1a). I would implement a regular
class completely with all dynamic methods (i.e. those Hash like
accesses like foo["bar"]) which translates these to calls of
#instance_variable_get and #instance_variable_set and only relies on
it's class having a method #members which returns a frozen Array of
Symbol containing member names. These will be stored in an instance
variable @members of the class. I would also depend on a method
#normalize_member with 1 argument in the class which raises an
exception if the argument is an invalid member and otherwise returns
the argument normalized (instance variable name). The class will have
another optional member @values which contains the value Hash if one
has been provided at class creation time. Now the class constructor
method (Structure.new) will only have to do this
1. create a subclass of the base class
2. set instance_variable "@members"
3. set instance_variable "@values" if present
4. class <<cl;self;end.class_eval { attr_accessor *members }
So we have something like
class Structure
class OpenStructure < Structure
def self.normalize_member(name) "@#{name}" end
def members; instance_variables.map {|iv| iv[/\A@(.*)\z/, 1].to_sym} en=
d
end
class <<self
attr_reader :members
def new(*args)
...
Class.new(self).tap do |cl|
cl.instance_variable_set("@members", members)
cl.instance_variable_set("@values", values) if values
end
end
end
def []=3D(name, value)
instance_variable_set(self.class.normalize(name), value)
end
def [](name)
instance_variable_get(self.class.normalize(name))
end
def hash
members.sort.inject(0) {|ha,o| ((ha << 3) ^ o.hash} # bad example!
end
def members
self.class.members
end
...
end
Done. :-)
Happy Easter!
robert
--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/