Skip to content

Instantly share code, notes, and snippets.

@tadman
Created March 19, 2009 17:24
Show Gist options
  • Save tadman/81950 to your computer and use it in GitHub Desktop.
Save tadman/81950 to your computer and use it in GitHub Desktop.
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),
(object.instance_methods.sort - Object.new.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