From: "Marvin Gülker" Date: 2010-02-18T02:12:59+09:00 Subject: Re: lookup up documentation for inherited methods Nick Brown wrote: > I find it frustrating when using "ri" to look up documentation on a > class, only to find the method I'm curious about is not listed. > > As an example: String objects have many more methods than are explained > in the documentation for String (example: String.grep). When you run > "ri" on String.grep, you get "Nothing known about String.grep". This is > apparently because the grep method was inherited from another class. > > Is there any way to have ri automatically check the documentation of > parent classes if no documentation is found for a method of a particular > object? Or is there a better way to access Ruby's documentation than "ri > Class.method"? I don't want to have to do detective work to look up a > simple method... Maybe you can't find the grep method in String, because it hasn't such a method? --------------------------------------- ruby -v: ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux] irb(main):001:0> "ABC".grep NoMethodError: undefined method `grep' for "ABC":String from (irb):1 from /home/marvin/Programmieren/Programme/ruby_shell/ruby_shell.rb:52:in `
' irb(main):002:0> --------------------------------------- And no, I don't know of a way to check inherited methods. But you could do --------------------------------------- ri grep More than one method matched your request. You can refine your search by asking for information on one of: Enumerable#grep [Ruby 1.9.1] Rake::FileList#egrep [gem rake-0.8.7] --------------------------------------- So, #grep is defined in Enumerable. Then you can look for Enumerable#grep. Marvin -- Posted via http://www.ruby-forum.com/.