Singleton classes and Namespce Do singleton classes not get the same namespace treatment as normal classes? module M class X; end end o = Object.new => #<Object:0x7fc61f1a1e58> (class << o; self; end).class_eval{ include M } => #<Object:0x7fc61f1a1e58> def o.x; X; end o.x => NameError: uninitialized constan... 7 Jun 2010 12:59
inject method of Array class I have only just started using Ruby (and am a total noob, in case this wasn't obvious ;-)) and was wondering if I type the following into irb (for instance) I don't see the "include" method listed: Array.methods Nor do I see the "each" method listed so I assume this is by design rather than being an omission. ... 7 Jun 2010 15:27
libruby-nntp doesn't exist any more ? libruby-nntp is referenced here : https://forge.secure.at:10443/projects/ruby-net-nntp/chrome/site/doc/ however : $ sudo gem1.9 install libruby-nntp ERROR: could not find gem libruby-nntp locally or in a repository does that means this module/class doesn't existe anymore ? -- � L� o� la v�rit� n'est pas li... 6 Jun 2010 14:55
How fast does your Ruby run? Program changed a little: n = 3_000_000 start_time = Time.now t = 0 1.upto(n) do |i| t = (1..10).inject {|x, y| x + y } end finish_time = Time.now p t puts RUBY_VERSION ||= "unknown version" RUBY_PATCHLEVEL ||= "unknown patchlevel" RUBY_PLATFORM ||= "unknown platform" print "Ruby ", RUBY_VE... 7 Jun 2010 15:27
[ANN] clogger 0.5.0 - body.to_path forwarding Clogger is Rack middleware for logging HTTP requests. The log format is customizable so you can specify exactly which fields to log. * http://clogger.rubyforge.org/ * clogger(a)librelist.com * git://git.bogomips.org/clogger.git Changes: This release allows middleware like Rack::Contrib::Sendfile to work pro... 6 Jun 2010 05:06
Please explain this "Why's" example please On Sun, Jun 6, 2010 at 12:50 PM, Kaye Ng <sbstn26(a)yahoo.com> wrote: After I type a word (and press an 'OK' button?), then what? Can anyone explain to me the role of Gets here? And also the Each block please. You may also give me another example with Gets and Each. First of all, it's "gets" and "each" - r... 8 Jun 2010 05:49
threads & mutex question (Rubyist book example) Hi, I am concerned about the lack of mutual exlusion in code listing 14.2 "Chat server using TCPServer and threads" on page 430 in "The Well-Grounded Rubyist" book. That code goes something like this: chatters = [] while ... Thread.new(...) do |c| chatters.each { ... } chatters.push c... 16 Jun 2010 11:01
1.9 warning for 'private' and possible bug Consider this error: $ cat t.rb module M private def attr_accessor(*args); super; end end class C extend M attr_accessor :x end C.new.x = 1 $ ruby19 t.rb t.rb:11:in `<main>': private method `x=' called for #<C:0x0000000091c670> (NoMethodError) That looks very suspect, so I was a... 5 Jun 2010 21:17
Processing (potentially) nil method without using nested if Hi all, really stupid question. How can I evaluate the following code without using a nested if.. then statement? if parent.respond_to? "children" if parent.children.size != 0 puts "Has children" end end Ideally I'd like to do: if parent.respond_to? "children" && parent.children.size != ... 7 Jun 2010 14:17
Clearing TOPLEVEL_BINDING for reuse Is there anyway to delete all the local and instance variables in a Binding? I've been working on a test framework and ideally I'd like the tests to run at the toplevel rather than within the scope of some class. But to do this I need to clear out the variables between each test script. ... 6 Jun 2010 00:32 |