Module: Kirillica::ISO_9

Defined in:
lib/kirillica/iso_9.rb

Constant Summary collapse

TABLE =
{
  'а' => 'a',
  'б' => 'b',
  'в' => 'v',
  'г' => 'g',
  'д' => 'd',
  'е' => 'e',
  'ё' => 'ё',
  'ж' => 'ž',
  'з' => 'z',
  'и' => 'i',
  'й' => 'j',
  'к' => 'k',
  'л' => 'l',
  'м' => 'm',
  'н' => 'n',
  'о' => 'o',
  'п' => 'p',
  'р' => 'r',
  'с' => 's',
  'т' => 't',
  'у' => 'u',
  'ф' => 'f',
  'х' => 'h',
  'ц' => 'c',
  'ч' => 'č',
  'ш' => 'š',
  'щ' => 'ŝ',
  'ъ' => '"',
  'ы' => 'y',
  'ь' => "'",
  'э' => 'è',
  'ю' => 'û',
  'я' => 'â',
}
WINDOW =
1

Class Method Summary collapse

Class Method Details

.revert!(phrase) ⇒ Object

invert transliteration



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/kirillica/iso_9.rb', line 55

def self.revert!(phrase)
  reverted_phrase = ''

  phrase.each_char do |char|
    reverted_char = TABLE.invert[char]
    raise 'cannot revert phrase' unless reverted_char

    reverted_phrase << reverted_char
  end

  reverted_phrase
end

.translit(phrase = '') ⇒ Object

transliteration



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/kirillica/iso_9.rb', line 42

def self.translit(phrase='')
  return '' if phrase.empty?
  translitted_phrase = ''

  phrase.each_char do |char|
    translitted_char = TABLE[char]
    translitted_phrase << (translitted_char.nil? ? char : translitted_char)
  end

  translitted_phrase
end