Class | String |
In: |
lib/ofac/ruby_string_extensions.rb
|
Parent: | Object |
Ofac_SoundexChars | = | 'BPFVCSKGJQXZDTLMNR' |
Ofac_SoundexNums | = | '111122222222334556' |
Ofac_SoundexCharsEx | = | '^' + Ofac_SoundexChars |
Ofac_SoundexCharsDel | = | '^A-Z' |
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