Created
April 22, 2012 05:44
-
-
Save soulcutter/2458278 to your computer and use it in GitHub Desktop.
irbrc helper to print documentation
This file contains 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
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 | |
system 'ri', method.to_s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment