I have started learning Rails 3.0 and decided to spend sometime learning Pure Ruby 1.9 and wonder if there is a way to View the Object Class since it is always available. Like is there a command that you can type in IRB for example that will display all the methods in Object Class like to_a, to_s, etc.. Thanks for any help
I have started learning Rails 3.0 and decided to spend sometime learning Pure Ruby
Share
#methodsis the method you want. It simply returns an array of symbols, which are all the names of the methods that object responds to.Or more readable in irb:
Or for the class methods:
One caveat though, some objects allow methods that won’t be listed here. Anything implemented with a hook into
#method_missingwon’t show up. This includes a lot ofActiveRecordmethods as well as other rails objects.But so long as nothing tricky is going on, this is the list you seem to want.