Created
May 28, 2011 22:33
-
-
Save iande/997300 to your computer and use it in GitHub Desktop.
Please Don't
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
class String | |
def levenshtein other | |
# .. left as exercise for the reader | |
end | |
class Object | |
def method_missing meth, *args, &block | |
meth_str = meth.to_s | |
new_meth = self.methods.map do |m| | |
[meth_str.levenshtein(m.to_s), m] | |
end.sort do |a,b| | |
a.first <=> b.first | |
end.first.last | |
__send__ new_meth, *args, &block | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment