Skip to content

Instantly share code, notes, and snippets.

@dcparker
Created March 2, 2010 17:45
Show Gist options
  • Save dcparker/319712 to your computer and use it in GitHub Desktop.
Save dcparker/319712 to your computer and use it in GitHub Desktop.
`man` command for IRB
module Kernel
def man(obj)
publ = obj.public_methods.sort - Object.public_methods - Kernel.public_methods
puts "Public:\n#{publ.join(', ')}"
priv = obj.private_methods.sort - Object.private_methods - Kernel.private_methods
puts "\nProtected:\n#{prot.join(', ')}" unless prot.empty?
prot = obj.protected_methods.sort - Object.protected_methods - Kernel.protected_methods
puts "\nPrivate:\n#{priv.join(', ')}" unless priv.empty?
ivars = obj.instance_variables
puts "\nInstance variables: #{ivars.join(', ')}" unless ivars.empty?
end
def man!(obj)
publ = obj.public_methods.sort - Kernel.public_methods
puts "Public:\n#{publ.join(', ')}"
priv = obj.private_methods.sort - Kernel.private_methods
puts "\nProtected:\n#{prot.join(', ')}" unless prot.empty?
prot = obj.protected_methods.sort - Kernel.protected_methods
puts "\nPrivate:\n#{priv.join(', ')}" unless priv.empty?
ivars = obj.instance_variables
puts "\nInstance variables: #{ivars.join(', ')}" unless ivars.empty?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment