Roger's woze

June 10, 2008

irb ri

Filed under: ruby — rogerdpack @ 2:31 am

yea!  The gem I always wanted!

Now in an irb session you can get instant documentation on methods that you use!
get it here
ex:

irb

require 'file_from_the_above_website.rb' # some code posted there

gem install fastri

then in a separate window

fastri-server

then irb

irb(main):009:0> [].ri_find
-------------------------------------------------------- Enumerable#find
enum.detect(ifnone = nil) {| obj | block }  => obj or nil
enum.find(ifnone = nil)   {| obj | block }  => obj or nil
------------------------------------------------------------------------
Passes each entry in enum to block. Returns the first for which
block is not false. If no object matches, calls ifnone and returns
its result when it is specified, or returns nil

(1..10).detect  {|i| i % 5 == 0 and i % 7 == 0 }   #=> nil
(1..100).detect {|i| i % 5 == 0 and i % 7 == 0 }   #=> 35

=> nil

tada!

3 Comments »

  1. then you can save that file to
    ~ sudo cp irb_lookup.rb /opt/local/lib/ruby/gems/1.8/gems/fastri-0.3.1.1/lib/fastri/
    then
    in ~/.irbrc
    add
    require ‘irb_lookup’ # works! happy irb!

    Comment by rogerdpack — June 10, 2008 @ 3:18 am

  2. [...] – bookmarked by 5 members originally found by t0ms on 2008-08-04 irb ri http://betterlogic.com/roger/?p=327 – bookmarked by 1 members originally found by jlawhead on [...]

    Pingback by Bookmarks about Irb — August 21, 2008 @ 9:45 am

  3. utility_belt is also ‘really nice’ for a quality irb experience :) Check it out!

    Comment by rogerdpack — August 24, 2008 @ 4:58 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress