Saari Development

Ali Rizvi's Technical Blog as a Professional Software Development Engineer

Ruby: ri Command Line Help

leave a comment »

Looking up help on ruby methods and classes from the command line sounds simple but can be very useful if you don’t know or don’t remember.

ri is the equivalent of ‘man’ command in unix (I always confuse this with rdoc which is for generating html documentation, I think perldoc has something to do with this confusion).

Some example commands are

prompt> ri Class
prompt> ri alias_method

In case multiple classes have the same method and you are searching for a method

prompt> ri method_missing

ri will show a message like this:

More than one method matched your request. You can refine
your search by asking for information on one of:

Delegator#method_missing, Kernel#method_missing

You can then look for the specific method using:

prompt> ri Kernel#method_missing

Update: I just discovered that Class#method is for instance methods, if you want to look help class methods then it is done using Class::method.


ri Hash::new # shows details of the Hash class's new method
ri Hash#delete # shows details of the hash instance's delete method

Also found this interesting reference:
Ruby RI – Using Ruby’s RI Documentation Reader


Written by imsaar

September 28, 2006 at 9:44 pm

Posted in general

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: