tawheed
tawheed

Reputation: 5821

Debugging ruby code in irb/pry

Is there a way to find out more information of what a method does in irb.

Example would be in irb/pry I could do something like this:

strigy_object = "I am string"

Now if i type stringy_object. and press the tab key, all the possible methods that stringy_object responds to would be listed. Since I am relatively new to ruby and not really familiar with all the methods, I would love to possibly find more information about what the method does. In short, is there a 'man' command equivalent that could help me achieve that in irb/pry?

Upvotes: 1

Views: 228

Answers (2)

user229044
user229044

Reputation: 239501

Use stringy_object.methods. It will return with all the methods the object responds to.

If you want to trim down that list to only methods specific to that type of object, you can do stringy_object.methods - Object.methods.

Upvotes: 0

Dave Newton
Dave Newton

Reputation: 160291

Use the show-doc command.

For some commands you'll need to gem install pry-doc (like for C commands).

Upvotes: 1

Related Questions