class String
Public Instance Methods
distance(other)
click to toggle source
Levenshtein distance, used to determine the minimum number of changes needed to modify a string into another one. It uses the Text gem for its UTF-8 enabled comparisons.
# File lib/acts_as_suggest.rb, line 121 def distance(other) Text::Levenshtein::distance(self, other) end
similar?(other, threshold = 2)
click to toggle source
Determines if two strings are similar based on a provided treshold.
# File lib/acts_as_suggest.rb, line 127 def similar?(other, threshold = 2) self.distance(other) <= threshold ? true : false end