class String

Constants

Ofac_SoundexChars
Ofac_SoundexCharsDel
Ofac_SoundexCharsEx
Ofac_SoundexNums

Public Instance Methods

ofac_soundex(census = true) click to toggle source

desc: en.wikipedia.org/wiki/Soundex

# File lib/ofac/ruby_string_extensions.rb, line 9
def ofac_soundex(census = true)
  str = upcase.delete(Ofac_SoundexCharsDel).squeeze

  str[0 .. 0] + str[1 .. -1].
    delete(Ofac_SoundexCharsEx).
    tr(Ofac_SoundexChars, Ofac_SoundexNums)[0 .. (census ? 2 : -1)].
    ljust(3, '0') rescue ''
end
ofac_sounds_like(other, census = true) click to toggle source
# File lib/ofac/ruby_string_extensions.rb, line 18
def ofac_sounds_like(other, census = true)
  ofac_soundex(census) == other.ofac_soundex(census)
end