Class: Tataki::Converter::Alphabet

Inherits:
Base
  • Object
show all
Defined in:
lib/tataki/converters/alphabet.rb

Instance Method Summary collapse

Constructor Details

#initializeAlphabet

Returns a new instance of Alphabet.



7
8
9
10
11
# File 'lib/tataki/converters/alphabet.rb', line 7

def initialize
  alphabet_file = File.expand_path("../../../../data/alphabet.yml", __FILE__)
  alphabet_data = YAML.load_file(alphabet_file)
  @table = alphabet_data["table"]
end

Instance Method Details

#to_kana(sentence) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/tataki/converters/alphabet.rb', line 13

def to_kana(sentence)
  kana = ""
  sentence.downcase.each_char do |ch|
    kana << (@table[ch] || ch)
  end
  kana
end