Class: ItaxCode::Transliterator

Inherits:
Object
  • Object
show all
Defined in:
lib/itax_code/transliterator.rb

Overview

Constant Summary collapse

DEFAULT_REPLACEMENT_CHAR =
"?"

Instance Method Summary collapse

Instance Method Details

#transliterate(string, replacement = nil) ⇒ Object



8
9
10
11
# File 'lib/itax_code/transliterator.rb', line 8

def transliterate(string, replacement = nil)
  replacement ||= DEFAULT_REPLACEMENT_CHAR
  string.gsub(/[^\x00-\x7f]/u) { |char| approximations[char] || replacement }
end