views:

125

answers:

3

Say I'm writing some ruby code and I want to use the standard Date type to get the current date. Instead of using a search engine, is there a faster way to find the documentation for this class? I know I can get the methods for Date by typing Date.methods, but as far as I know this doesn't provide details about argument types or return value.

Editor-specific answers are welcomed. My editor of choice is Emacs.

+3  A: 

On your console use "ri"

ri Date

That works with all classes. (e.g. ri String) To see documentation for a particular method you use this:

ri Date#yourMethod
daddz
or rather ri 'Date.yourMethod' ;-)
webmat
+1  A: 

The canonical source for Ruby documentation is Ruby-doc - the two links there which are of the most interest are core and standard library. You get a javadoc-style representation which usually covers argument types and return values. You can even make your own with RDoc.

Atiaxi
+3  A: 

Bookmark the ruby core docs

Use your web browser's find-text command.

Unexpected as it may seem, I find this is actually quicker than using ri, which for some reason seems to take ages to start up.

It is also much better than ri because the HTML page lists all the documentation for all the methods on a single page. Often methods are related to others, and switching between 2 ri's is painful

Orion Edwards