Created
March 2, 2010 17:45
-
-
Save dcparker/319712 to your computer and use it in GitHub Desktop.
`man` command for IRB
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
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