Kurt Stephens

Nerd Up!

Recent comments

Random image

Latest image

Syndicate

Syndicate content

Browse archives

« August 2008  
Mo Tu We Th Fr Sa Su
        1 2 3
4 5 6 7 9
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Kurt on Sat, 2007-12-15 03:02.

Helpful in IRB:


class Regexp
  def to_proc
    @proc ||= lambda { | x | self.match(x) }
  end
end

As in:


irb(main):001:0> pp Object.methods.sort.select(&/meth/)
["instance_method",
 "instance_methods",
 "method",
 "method_defined?",
 "methods",
 "private_class_method",
 "private_instance_methods",
 "private_method_defined?",
 "private_methods",
 "protected_instance_methods",
 "protected_method_defined?",
 "protected_methods",
 "public_class_method",
 "public_instance_methods",
 "public_method_defined?",
 "public_methods",
 "singleton_methods"]
=> nil
irb(main):002:0> pp Object.methods.sort.find(&/def/)
"const_defined?"
=> nil

W00t!


links: read more | Kurt's blog | 2 comments | 531 reads

Reply

The content of this field is kept private and will not be shown publicly.
Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.