Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ofac/ruby_string_extensions.rb
Constant Summary collapse
- Ofac_SoundexChars =
'BPFVCSKGJQXZDTLMNR'
- Ofac_SoundexNums =
'111122222222334556'
- Ofac_SoundexCharsEx =
'^' + Ofac_SoundexChars
- Ofac_SoundexCharsDel =
'^A-Z'
Instance Method Summary collapse
Instance Method Details
#ofac_soundex(census = true) ⇒ Object
9 10 11 12 13 14 15 16 |
# 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) ⇒ Object
18 19 20 |
# File 'lib/ofac/ruby_string_extensions.rb', line 18 def ofac_sounds_like(other, census = true) ofac_soundex(census) == other.ofac_soundex(census) end |