module Tibetan
Constants
- CHARACTER_TABLE
Extended Wylie Transliteration Scheme (EWTS)
- CONSONANTS
- DEFAULT_VOWEL
- SEP
- SUBSCRIPTS
- VERSION
- VOWELS
Public Class Methods
insert_default_vowel!(string="")
click to toggle source
# File lib/tibetan.rb, line 151 def insert_default_vowel!(string="") # 1. after subscript if (string.chars & VOWELS).empty? index = string.rindex(/#{SUBSCRIPTS.join('|')}/) string = string.insert(index+1, DEFAULT_VOWEL) unless index.nil? end # 2. after consonant, if not added in 1st step if (string.chars & VOWELS).empty? && (string.chars & CONSONANTS).any? index = string.size > 2 ? 1 : 0 string = string.insert(index+1, DEFAULT_VOWEL) unless index.nil? end end
transliterate(string="", to=:tibetan)
click to toggle source
# File lib/tibetan.rb, line 134 def transliterate(string="", to=:tibetan) string = string.to_s # Split long phrase into small parts and transliterate separately if string.split(SEP).size > 1 string = string.split(SEP).map do |str| transliterate(str) end.join(SEP) end insert_default_vowel!(string) character_table = Module.const_get(to.to_s.capitalize)::CHARACTER_TABLE string.to_s.gsub(/#{Regexp.union(character_table.keys).source}/i, character_table) end
Also aliased as: t