Sha256: 9e75b652a9606adcab802f1f2298b6be2fd345966aab703c4ac68530dca2e789

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

require_relative "sushi_yakuza/version"
require "csv"

module SushiYakuza
  class Error < StandardError; end

  def self.to_kanji(sushi_name)
    search_sushi(sushi_name, "to_kanji")
  end

  def self.to_hiragana(sushi_name)
    search_sushi(sushi_name, "to_hiragana")
  end

  def search_sushi(sushi_name, conv_type)
    CSV.foreach("lib/csv/sushi_data.csv") do |row|
      if conv_type == "to_hiragana"
        return row[1] if row[0] == sushi_name
      elsif conv_type == "to_kanji"
        return row[0] if row[1] == sushi_name || row[2] == sushi_name
      end
    end
    return false
  end

  module_function :search_sushi
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sushi_yakuza-0.1.1 lib/sushi_yakuza.rb