Class: Tataki::Converter::Alphabet
- Defined in:
- lib/tataki/converters/alphabet.rb
Instance Method Summary collapse
-
#initialize ⇒ Alphabet
constructor
A new instance of Alphabet.
- #to_kana(sentence) ⇒ Object
Constructor Details
#initialize ⇒ Alphabet
Returns a new instance of Alphabet.
7 8 9 10 11 |
# File 'lib/tataki/converters/alphabet.rb', line 7 def initialize alphabet_file = File.("../../../../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 |