Created
April 12, 2017 20:09
-
-
Save ch1ago/38953df2b57a111cc92d9d02f5f6972e to your computer and use it in GitHub Desktop.
irbrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'irb/completion' | |
require 'irb/ext/save-history' | |
require 'rubygems' | |
IRB.conf[:SAVE_HISTORY] = 1000 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" | |
IRB.conf[:PROMPT_MODE] = :SIMPLE | |
IRB.conf[:AUTO_INDENT] = true | |
# returns the instance methods on klass | |
# that aren't already on Object | |
def m(klass) | |
klass.public_instance_methods - Object.public_instance_methods | |
end | |
class Object | |
# list methods which aren't in superclass | |
def local_methods(obj = self) | |
(obj.methods - obj.class.superclass.instance_methods).sort | |
end | |
# print documentation | |
# | |
# ri 'Array#pop' | |
# Array.ri | |
# Array.ri :pop | |
# arr.ri :pop | |
def ri(method = nil) | |
unless method && method =~ /^[A-Z]/ # if class isn't specified | |
klass = self.kind_of?(Class) ? name : self.class.name | |
method = [klass, method].compact.join('#') | |
end | |
puts `ri '#{method}'` | |
end | |
end | |
def me | |
User.find_by_login(ENV['USER'].strip) | |
end | |
def r | |
reload! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment