In my application I need an “edit_distance” method that computes the
Edit Distance (Also called Levenshtein Distance, see this:
http://en.wikipedia.org/wiki/Levenshtein_distance) between two
strings. I wonder where is the right place to put this method. I have
a “utils” Ruby file with various extensions to classes and modules
that make my life easier. So there are two options:
- Have a global (Kernel) method named “edit_distance” that accepts
- Add a “edit_distance_from” method to the String class that accepts
the “other” string
Which approach is better, in your opinion ?
P.S: There are lots of Edit Distance implementations in Ruby online.