Skip to content

Instantly share code, notes, and snippets.

@FrancoB411
Forked from kurioscreative/gist:803257
Created January 30, 2011 23:24
Show Gist options
  • Select an option

  • Save FrancoB411/803398 to your computer and use it in GitHub Desktop.

Select an option

Save FrancoB411/803398 to your computer and use it in GitHub Desktop.
class ObjectPrinter
#changed param name to item so it's clearer we're sticking an "item" in there and not the class "ObjectPrinter" itself
def print_methods(item)
#added a little space and header to make it easier to read
3.times {puts ""}
puts "#{item} methods:"
puts "----------------------------"
puts ""
#numbered the methods for legibility
for method in item.public_instance_methods
@count ||= 0
puts "#{@count +=1}: #{method}"
puts "\n"
end
puts "----------------------------"
end
end
t = ObjectPrinter.new
t.print_methods(Dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment