Thanks for making this gem, it's great. Here's an idea for an alternative interface:
10.methodfinder do |n|
n.unknown(3) == 1
Calling methodfinder on an object would loop through the block for each possible method substituting it as unknown. If the block returns true it returns the method. The advantage of this approach is you can test state outside of what is returned by the method.
%w[a b c].methodfinder do |a|
a == %w[a c]
Here it would show delete_at since that results in removing the 1 indexed element from the array.
Thanks Ryan, I like the general idea, but I'm not (yet) convinced by the interface. Let me ponder this for a bit, I'm sure we can come up with a cool way to do this :-)
If you don't like inserting methods onto objects you could keep the MethodFinder.find() syntax and use this approach only when one argument and a block is supplied. A proxy object can be passed to the block so the passed in object isn't messed with.
While I normally don't like adding methods to objects like this, here I don't consider it to be a problem because this is more of a tool used in IRB and not something you'll be including into a production app.
Added, but I decided to call it find_method.
Awesome, looks great, thanks!