Section 21.5. Editor Support


21.4. The ri Utility

The ri is apparently named from "Ruby index" or some such mnemonic. It is a command-line documentation tool, offering information on Ruby classes, methods, modules, and so on. Here is an example:

$ ri each_with_index --------------------------------------------------------   enumObj.each_with_index {| obj, i | block }  -> nil --------------------------------------------------------   Calls block with two arguments, the item and its index,   for each item in enumObj.      hash = Hash.new      %w(cat dog wombat).each_with_index {|item, index|        hash[item] = index      }      hash   #=> {"dog"=>1, "wombat"=>2, "cat"=>0}


Note that it has a few bugs and quirks. You are encouraged to report these (along with typos and other inaccuracies) if you can find anyone who claims to own it.

Martin Ankerl has a GUI version called fxri that works well. It draws its data from the RDoc information just as the command-line ri does. It also conveniently has a pane devoted to irb.




The Ruby Way(c) Solutions and Techniques in Ruby Programming
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2004
Pages: 269
Authors: Hal Fulton

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net