Created
March 30, 2011 20:11
-
-
Save pvdb/895200 to your computer and use it in GitHub Desktop.
MethodFinder and irb via .irbrc
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
| # | |
| # https://github.com/citizen428/methodfinder | |
| # | |
| # stick the below snippet in your .irbrc file | |
| # in order to be able to do something like... | |
| # | |
| # irb :001 > ' blegga '.method_finder 'blegga' | |
| # => [:strip, :strip!] | |
| # irb :002 > 'blegga'.method_finder 6 | |
| # => [:bytesize, :length, :size] | |
| # irb :003 > _ | |
| # | |
| # MAJOR caveat emptor: | |
| # | |
| # http://twitter.com/dkubb/statuses/52840847816933376 | |
| # | |
| begin | |
| require 'methodfinder' | |
| class Object | |
| # find the methods that return the given result | |
| def method_finder(result) | |
| MethodFinder.find(self, result) | |
| end | |
| end | |
| rescue LoadError | |
| # noop in case we cannot load the gem | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment