Class: UkrainianLatin

Inherits:
Object
  • Object
show all
Defined in:
lib/uklatn.rb

Overview

Ukrainian Cyrillic transliteration to and from Latin script.

Tables:

  • ‘DSTU_9112_A’: DSTU 9112:2021 System A

  • ‘DSTU_9112_B’: DSTU 9112:2021 System B

  • ‘KMU_55’: KMU 55:2010, not reversible

Usage:

tr = UkrainianLatin.new
tr.encode('Доброго вечора!')
tr.decode('Paljanycja')

Select a transliteration scheme:

tr.encode('Борщ', 'DSTU_9112_A')

Defined Under Namespace

Classes: Uklatn_uk_Latn_DSTU_9112_A_uk, Uklatn_uk_Latn_DSTU_9112_B_uk, Uklatn_uk_uk_Latn_DSTU_9112_A, Uklatn_uk_uk_Latn_DSTU_9112_B, Uklatn_uk_uk_Latn_KMU_55

Constant Summary collapse

TABLES =

:nodoc:

Hash.new([nil, nil])

Instance Method Summary collapse

Instance Method Details

#decode(text, table = 'DSTU_9112_A') ⇒ Object

Re-transliterates a string of Ukrainian Latin to Cyrillic script.

Raises:

  • (ArgumentError)


28
29
30
31
32
# File 'lib/uklatn.rb', line 28

def decode(text, table = 'DSTU_9112_A')
    tr = TABLES[table][1]
    return tr.transform(text) if tr
    raise ArgumentError.new("invalid table #{table}")
end

#encode(text, table = 'DSTU_9112_A') ⇒ Object

Transliterates a string of Ukrainian Cyrillic to Latin script.

Raises:

  • (ArgumentError)


21
22
23
24
25
# File 'lib/uklatn.rb', line 21

def encode(text, table = 'DSTU_9112_A')
    tr = TABLES[table][0]
    return tr.transform(text) if tr
    raise ArgumentError.new("invalid table #{table}")
end