class String

Constants

EN_RU
RU_EN
UA_EN

Public Instance Methods

translit(options = { from: 'en', to: 'ru' }) click to toggle source
# File lib/translit_net.rb, line 26
def translit(options = { from: 'en', to: 'ru' })
  h = EN_RU
  h = if ru_en?(options)
    RU_EN
  elsif ua_en?(options)
    UA_EN
  end

  self.split('').map do |char|
    h[char] ? h[char] : char
  end.join('')
end

Private Instance Methods

ru_en?(options) click to toggle source
# File lib/translit_net.rb, line 41
def ru_en?(options)
  options && options[:from] == 'ru' && options[:to] == 'en'
end
ua_en?(options) click to toggle source
# File lib/translit_net.rb, line 45
def ua_en?(options)
  options && options[:from] == 'ua' && options[:to] == 'en'
end