Class: UkrainianLatin::Uklatn_uk_Latn_DSTU_9112_A_uk
- Inherits:
-
Object
- Object
- UkrainianLatin::Uklatn_uk_Latn_DSTU_9112_A_uk
- Defined in:
- lib/uklatn.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize ⇒ Uklatn_uk_Latn_DSTU_9112_A_uk
constructor
A new instance of Uklatn_uk_Latn_DSTU_9112_A_uk.
- #transform(text) ⇒ Object
Constructor Details
#initialize ⇒ Uklatn_uk_Latn_DSTU_9112_A_uk
Returns a new instance of Uklatn_uk_Latn_DSTU_9112_A_uk.
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/uklatn.rb', line 111 def initialize() @rx1 = /([ÁáÉéÍíÓóÚúÝýḮḯ])/ @maps1 = [ {"Á"=>"Á","á"=>"á","É"=>"É","é"=>"é","Í"=>"Í","í"=>"í","Ó"=>"Ó","ó"=>"ó","Ú"=>"Ú","ú"=>"ú","Ý"=>"Ý","ý"=>"ý","Ḯ"=>"Ḯ","ḯ"=>"ḯ"}, ] @rx2 = /(J[Ee]|j[Ee]|J[Uu]|j[Uu]|J[Aa]|j[Aa]|[A-GIK-PR-VXYZa-gik-pr-vxyzÏÖïöČčĒēĞğĴĵŜŝŠšŬŭŽžǑǒȲȳ])|(?<=[BbCcDdFfGgKkLlMmNnPpRrSsTtVvXxZzČčĞğŜŝŠšŽž])([Jj]\u0027(?=[AaEeUu])|[Jj])|(\u0027[Jj](?![AaEeIiUu])|\u0027(?=[Jj])|[Jj])/ @maps2 = [ {"A"=>"А","a"=>"а","B"=>"Б","b"=>"б","V"=>"В","v"=>"в","Ğ"=>"Г","ğ"=>"г","G"=>"Ґ","g"=>"ґ","D"=>"Д","d"=>"д","E"=>"Е","e"=>"е","JE"=>"Є","Je"=>"Є","jE"=>"є","je"=>"є","Ž"=>"Ж","ž"=>"ж","Z"=>"З","z"=>"з","Y"=>"И","y"=>"и","I"=>"І","i"=>"і","Ï"=>"Ї","ï"=>"ї","K"=>"К","k"=>"к","L"=>"Л","l"=>"л","M"=>"М","m"=>"м","N"=>"Н","n"=>"н","O"=>"О","o"=>"о","P"=>"П","p"=>"п","R"=>"Р","r"=>"р","S"=>"С","s"=>"с","T"=>"Т","t"=>"т","U"=>"У","u"=>"у","F"=>"Ф","f"=>"ф","X"=>"Х","x"=>"х","C"=>"Ц","c"=>"ц","Č"=>"Ч","č"=>"ч","Š"=>"Ш","š"=>"ш","Ŝ"=>"Щ","ŝ"=>"щ","JU"=>"Ю","Ju"=>"Ю","jU"=>"ю","ju"=>"ю","JA"=>"Я","Ja"=>"Я","jA"=>"я","ja"=>"я","Ĵ"=>"Ь","ĵ"=>"ь","Ö"=>"Ё","ö"=>"ё","Ŭ"=>"Ў","ŭ"=>"ў","Ǒ"=>"Ъ","ǒ"=>"ъ","Ȳ"=>"Ы","ȳ"=>"ы","Ē"=>"Э","ē"=>"э"}, {"J"=>"Ь","j"=>"ь","J'"=>"Ь","j'"=>"ь"}, {"'J"=>"Й","'j"=>"й","'"=>"’","J"=>"Й","j"=>"й"}, ] end |
Instance Method Details
#transform(text) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/uklatn.rb', line 124 def transform(text) text = text.unicode_normalize(:nfc) text = text.gsub(@rx1) do |m| next @maps1[0].fetch($1, $1) unless $1.nil? m end text = text.gsub(@rx2) do |m| next @maps2[2].fetch($3, $3) unless $3.nil? next @maps2[1].fetch($2, $2) unless $2.nil? next @maps2[0].fetch($1, $1) unless $1.nil? m end text = text.unicode_normalize(:nfc) end |