Dirby

Dirby is an enhancement for the IRB environment, which initially borrowed from the Wirble [1] project. It's goal is to provide enhancements to the interaction Ruby shell known as IRB.

Installing Dirby

To install the latest release of Dirby, simply install the gemfile, available:

gem install dirby

Using Dirby

To make Dirby available, simply add the following to your ~/.irbrc file:

begin require 'dirby' Dirby.init rescue LoadError => error $stderr.puts "Could not load Dirby: #error" end

View Ruby Documentation

To view rdoc information on an object, you invoke the ri method dynamically added to all classes loaded in IRB, and then optionally specify the method to interrogate. For example, to view the information on a single class:

1.9.1-p431 :002 > r String
------------------------------------------------- Class: String < Object
     A +String+ object holds and manipulates an arbitrary sequence of
     bytes, typically representing characters. String objects may be
     created using +String::new+ or as literals.

     Because of aliasing issues, users of strings should be aware of the
     methods that modify the contents of a +String+ object. Typically,
     methods with names ending in ``!'' modify their receiver, while
     those without a ``!'' return a new +String+. However, there are
     exceptions, such as +String#[]=+.

     Rake extension methods for String.

------------------------------------------------------------------------


Includes:
---------

     Comparable
# The rest excluded for brevity

To view documentation for a method or field it gets a little more complicated. The separate between the class and the method name is either a has (#) or a period (.), the former being also the comment character for the Ruby parser. So to get inline docs, you need to wrap the whole name in quotes:

1.9.1-p431 :001 > r 'String.upcase'
---------------------------------------------------------- String#upcase
     str.upcase   => new_str

------------------------------------------------------------------------
     Returns a copy of _str_ with all lowercase letters replaced with
     their uppercase counterparts. The operation is locale
     insensitive---only characters ``a'' to ``z'' are affected. Note:
     case replacement is effective only in ASCII region.

        "hEllO".upcase   #=> "HELLO"

NOTES

[1] http://pablotron.org/software/wirble/