Class: Iuliia::Translit

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

Instance Method Summary collapse

Constructor Details

#initialize(string, schema) ⇒ Iuliia::Translit

Initialize transliterator engine with string and schema

Parameters:



12
13
14
15
# File 'lib/iuliia/translit.rb', line 12

def initialize(string, schema)
  @string = string
  @schema = Iuliia::Schema[schema]
end

Instance Method Details

#translitString

Translit cyrillic string to latin representation

Returns:

  • (String)


19
20
21
22
23
# File 'lib/iuliia/translit.rb', line 19

def translit
  return unless schema

  string.split(/\b/).map { |chunk| translit_chunk(chunk) }.join
end