I use Ruby’s irb shell for everyday activities – as a calculator; for writing small code snippets; trying out code snippets; Ruby class documentation etc. The irb shell can be customized using the .irbrc file, usually located in the users home directory. This is a copy of my .irbrc file that I use on Windows PCs.
#-- for wirble # wirble is a wonderful gem which add nice features to irb begin ENV['IRB_HISTORY_FILE'] = "c:\ruby\.irb_history" # load wirble require 'wirble' wirble_opts = { :skip_prompt => true } # start wirble Wirble.init(wirble_opts) # Wirble.colorize [Colorize doesn't seem to work on Windows!] rescue LoadError => err warn "Couldn't load Wirble: #{err}" end # List non-trivial methods on any class class Object # Return only the methods not present on basic objects def interesting_methods (self.methods - Object.new.methods).sort end end #-- For Summable # Add Summable functionality to Arrays and Ranges module Summable def sum inject(0) { |x, y| x + y } end end class Array include Summable end class Range include Summable end #-- Simplify converting numbers to hex module Hexable def hex '0x' + to_s(16) end end class Fixnum include Hexable end class Bignum include Hexable end # pretty print --> provides a "pretty" view of an object require 'pp'
naahma
9noegq
zv3o1l
sm1f1d