21.4. The ri UtilityThe 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. |