module Kirillica::Passport
Constants
- DIPHTHONGS
- TABLE
- WINDOW
Public Class Methods
revert!(phrase)
click to toggle source
invert transliteration
# File lib/kirillica/passport.rb, line 82 def self.revert!(phrase) # TODO end
translit(phrase='')
click to toggle source
transliteration
# File lib/kirillica/passport.rb, line 53 def self.translit(phrase='') return '' if phrase.empty? translitted_phrase = '' chars = phrase.downcase.chars while chars.any? window = 2 if diphthong = DIPHTHONGS[chars.take(window).join] c = diphthong.is_a?(Array) ? diphthong.first : diphthong translitted_phrase << c chars.drop(window) else translitted_char = TABLE[chars.first] if translitted_char.nil? translitted_phrase << chars.first else c = translitted_char.is_a?(Array) ? translitted_char.first : translitted_char translitted_phrase << c end chars = chars.drop(1) end end translitted_phrase end