midwire
1/19/2015 - 7:11 PM

[My .irbrc] A useful .irbrc and .pryrc file #ruby

[My .irbrc] A useful .irbrc and .pryrc file #ruby

require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"

def what_methods(obj)
  (obj.public_methods - Object.publi_methods - Object.instance_methods).sort
end

def wm(obj)
  what_methods(obj)
end

def predicates(obj)
  what_methods(obj).grep(/\?$/)
end

def locate(obj, method)
  obj.method(method.to_sym).source_location
end