-
-
Save FrancoB411/803398 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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