Class: UkrainianLatin::Uklatn_uk_uk_Latn_DSTU_9112_A
- Inherits:
-
Object
- Object
- UkrainianLatin::Uklatn_uk_uk_Latn_DSTU_9112_A
- Defined in:
- lib/uklatn.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize ⇒ Uklatn_uk_uk_Latn_DSTU_9112_A
constructor
A new instance of Uklatn_uk_uk_Latn_DSTU_9112_A.
- #transform(text) ⇒ Object
Constructor Details
#initialize ⇒ Uklatn_uk_uk_Latn_DSTU_9112_A
Returns a new instance of Uklatn_uk_uk_Latn_DSTU_9112_A.
35 36 37 38 39 40 41 42 |
# File 'lib/uklatn.rb', line 35 def initialize() @rx1 = /\b([Ьь])|([Ьь](?=[АаЕеУу])|[ЄЮЯ](?=\u0301?[а-щьюяєіїґ’])|(?<=[Б-ДЖЗК-НП-ТФ-Щб-джзк-нп-тф-щҐґ])[Йй])|([ЁЄІЇЎА-яёєіїўҐґ’])/ @maps1 = [ {"Ь"=>"Ĵ","ь"=>"ĵ"}, {"Ь"=>"J'","ь"=>"j'","Є"=>"Je","Ю"=>"Ju","Я"=>"Ja","Й"=>"'J","й"=>"'j"}, {"А"=>"A","а"=>"a","Б"=>"B","б"=>"b","В"=>"V","в"=>"v","Г"=>"Ğ","г"=>"ğ","Ґ"=>"G","ґ"=>"g","Д"=>"D","д"=>"d","Е"=>"E","е"=>"e","Є"=>"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","Я"=>"JA","я"=>"ja","Ь"=>"J","ь"=>"j","Й"=>"J","й"=>"j","’"=>"'","Ё"=>"Ö","ё"=>"ö","Ў"=>"Ŭ","ў"=>"ŭ","Ъ"=>"Ǒ","ъ"=>"ǒ","Ы"=>"Ȳ","ы"=>"ȳ","Э"=>"Ē","э"=>"ē"}, ] end |
Instance Method Details
#transform(text) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/uklatn.rb', line 44 def transform(text) text = text.unicode_normalize(:nfc) text = text.gsub(@rx1) do |m| next @maps1[2].fetch($3, $3) unless $3.nil? next @maps1[1].fetch($2, $2) unless $2.nil? next @maps1[0].fetch($1, $1) unless $1.nil? m end text = text.unicode_normalize(:nfc) end |