lib/picky/extensions/symbol.rb in picky-3.5.4 vs lib/picky/extensions/symbol.rb in picky-3.6.0

- old
+ new

@@ -1,8 +1,30 @@ # Extending the Symbol class. # class Symbol # :nodoc:all + # Returns a _single_ double metaphone code + # for this symbol. + # + def double_metaphone + codes = Text::Metaphone.double_metaphone self + codes.first.intern unless codes.empty? + end + + # Returns a metaphone code for this symbol. + # + def metaphone + code = Text::Metaphone.metaphone self.to_s + code.intern if code + end + + # Returns a soundex code for this symbol. + # + def soundex + code = Text::Soundex.soundex self.to_s + code.intern if code + end + # :keys.each_subtoken # => yields each of [:keys, :key, :ke, :k] # :keys.each_subtoken(2) # => yields each of [:keys, :key, :ke] # def each_subtoken from_length = 1, range = nil sub = self.id2name \ No newline at end of file