Ruby 2 ri Tools

ri and RDoc

If you have a good internet connection, then you would probably refer to the Ruby documentation online. However, for those with a slower connection or not having an internet access, the Ruby ri and RDoc tools are very useful.
ri (Ruby Index) and RDoc (Ruby Documentation) are a closely related pair of tools for providing documentation about Ruby programs. ri is a command-line tool; the RDoc system includes the command-line tool rdocri and rdoc are standalone programs; you run them from the command line.
RDoc is a documentation system. If you put comments in your program files (Ruby or C) in the prescribed RDocformat, rdoc scans your files, extracts the comments, organizes them intelligently (indexed according to what they comment on), and creates nicely formatted documentation from them. You can see RDoc markup in many of the C files in the Ruby source tree and many of the Ruby files in the Ruby installation.
The Ruby ri tool is used to view the Ruby documentation off-line. Open a command window and invoke ri followed by the name of a Ruby class, module or method. ri will display documentation for you. You may specify a method name without a qualifying class or module name, but this will just show you a list of all methods by that name (unless the method is unique). Normally, you can separate a class or module name from a method name with a period. If a class defines a class method and an instance method by the same name, you must instead use :: to refer to a class method or # to refer to the instance method. Here are some example invocations of ri:
  1. ri Array  
  2. ri Array.sort  
  3. ri Hash#each  
  4. ri Math::sqrt  
ri dovetails with RDoc: It gives you a way to view the information that RDoc has extracted and organized. Specifically (although not exclusively, if you customize it), ri is configured to display the RDoc information from the Ruby source files.