Ruby: Grep the Object.methods's array
When your object has too many methods, search something on Object.methods's array is a pain in the ass. I wondered if there's a way to grep it and the answer is yes, there is.
If you are looking for a particular method of an object, you can narrow down the search appending .grep /string/ to Object.methods. For example:
Object.methods.grep /inspect/
=> ["inspect", "pretty_inspect", "pretty_print_inspect"]Written by Rômulo Machado
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
 #Ruby 
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#

 
 
 
 
