Created
December 9, 2008 22:06
-
-
Save tadman/34117 to your computer and use it in GitHub Desktop.
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
def pm(object) | |
identifiers = %w[ + - > ] | |
list = | |
case (object) | |
when Class: | |
puts "#{object} (Class)" | |
[ | |
(object.methods.sort - Class.methods), | |
(object.private_methods.sort - Class.private_methods), | |
(object.protected_methods.sort - Class.protected_methods) | |
] | |
else | |
puts object.class | |
[ | |
(object.methods.sort - Object.instance_methods), | |
(object.private_methods.sort - Object.private_instance_methods), | |
(object.protected_methods.sort - Object.protected_instance_methods) | |
] | |
end | |
list.each_with_index do |methods, i| | |
methods.group_by { |v| v.sub(/[^\w]$/, '') }.values.each do |method_group| | |
puts " %s %s" % [ identifiers[i], method_group.join(', ') ] | |
end | |
end | |
list.flatten.length - 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment