Sha256: 39afb9a0a84065c5087a445828f11dc00d2a15760157840c8d1d419ea62fa81e

Contents?: true

Size: 526 Bytes

Versions: 3

Compression:

Stored size: 526 Bytes

Contents

# coding: utf-8
require "yaml"

module Tataki
  module Converter
    class Alphabet < Base
      def initialize
        alphabet_file = File.expand_path("../../../../data/alphabet.yml", __FILE__)
        alphabet_data = YAML.load_file(alphabet_file)
        @table = alphabet_data["table"]
      end

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

  Tataki::CONVERTERS << Converter::Alphabet
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tataki-0.0.4 lib/tataki/converters/alphabet.rb
tataki-0.0.3 lib/tataki/converters/alphabet.rb
tataki-0.0.2 lib/tataki/converters/alphabet.rb