Skip to content

Instantly share code, notes, and snippets.

@iande
Created May 28, 2011 22:33
Show Gist options
  • Save iande/997300 to your computer and use it in GitHub Desktop.
Save iande/997300 to your computer and use it in GitHub Desktop.
Please Don't
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