A useful .irbrc file

Tweaking irb.

For better or worse, programming in Ruby means that you will be spending a lot of time in irb. You can customise its behaviour in your .irbrc file, usually found in your home directory. The tweaks in mine were gathered from various places across the 'net:

require "rubygems"
require "wirble"
require "irb"

# install and use the wirble gem, it does a lot of neat stuff
Wirble.init
Wirble.colorize

# the default colors suck, mod to use your own colors =
Wirble::Colorize.colors.merge({
   # set the comma color to blue
   :comma => :green,
   :refers => :green,
})

# to handle mistyping - "did you mean ..."
require 'guessmethod'

class Object
   # what methods are here that are not present on basic objects?
   def interesting_methods
      (self.methods - Object.new.methods).sort
   end

   def which_method (method_name)
      self.method(method_name.to_sym)
   end
end