Class String
In: lib/ofac/ruby_string_extensions.rb
Parent: Object

Methods

Constants

Ofac_SoundexChars = 'BPFVCSKGJQXZDTLMNR'
Ofac_SoundexNums = '111122222222334556'
Ofac_SoundexCharsEx = '^' + Ofac_SoundexChars
Ofac_SoundexCharsDel = '^A-Z'

Public Instance methods

desc: en.wikipedia.org/wiki/Soundex

[Source]

# 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

[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

[Validate]