Skip to content

Instantly share code, notes, and snippets.

@soulcutter
Created April 22, 2012 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soulcutter/2458278 to your computer and use it in GitHub Desktop.
Save soulcutter/2458278 to your computer and use it in GitHub Desktop.
irbrc helper to print documentation
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