From: Roger Pack Date: 2010-02-18T02:36:49+09:00 Subject: Re: lookup up documentation for inherited methods > 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... Hmm. There is a little utility I use within irb (for me it's easier than rdoc or ri) $ gem install ri_for It doesn't appear helpful in this case (except for telling us that String might well not have that method). It does, however, lookup ancestors appropriately if that were the problem, and run ri against the "right" ancestor. >> require 'ri_for' => true >> ''.ri_for :grep NameError: undefined method `grep' for class `String' from E:/installs/ruby191p376/lib/ruby/gems/1.9.1/gems/ri_for-0.5.1/lib/ri_for/method_ri.rb:180:in `method' from (irb):2 >> String.ri_for :grep NameError: appears that this object String does not have this method grep from E:/installs/ruby191p376/lib/ruby/gems/1.9.1/gems/ri_for-0.5.1/lib/ri_for/method_ri.rb:170:in `ri_for' from (irb):3 from E:/installs/ruby191p376/bin/irb:12:in `
' The way ri_for determines the "real" ancestor is to do a .method(:name) call on it, like >> ''.method(:select) => # within the #inspect output it tells me the real ancestor is Kernel. GL! -rp -- Posted via http://www.ruby-forum.com/.