Return to Snippet

Revision: 2715
at March 31, 2007 08:36 by vanne


Initial Code
#drop this in .irbrc
class Object
  def search_methods(string)
    search_results = ["--","CLASS METHODS","--"]
    search_results << self.methods.find_all{ |i| i.match(/#{string}/) }.sort 
    search_results << ["--", "INSTANCE METHODS","--"]
    search_results << self.instance_methods.find_all{ |i| i.match(/#{string}/) }.sort
    return y(search_results)
  end
end

# now just call #Object.search_methods "your_search" in irb to find a method

Initial URL
http://wiki.m001.net/technical/show/.irbrc

Initial Description
This allows you to search any INSTANCE or CLASS methods of any objects including rails models, which is helpful if you want to see the methods that you created yourself.

Initial Title
Search Methods in irb

Initial Tags
ruby

Initial Language
Ruby