class KanjiMaster::Converter

Public Class Methods

new(api_key: nil) click to toggle source
# File lib/kanji_master/converter.rb, line 6
def initialize(api_key: nil)
  @api_key = api_key
end

Public Instance Methods

hira(text) click to toggle source
# File lib/kanji_master/converter.rb, line 22
def hira(text)
  if text.match(RegexConstant::HIRAGANA_REGEX)
    text
  elsif text.match(RegexConstant::KATAKANA_REGEX)
    NKF.nkf("--hiragana -Ww", text)
  elsif text.match(RegexConstant::ROMAJI_REGEX)
    Romaji.romaji2kana text, :kana_type => :hiragana
  end
end
hiragana(text) click to toggle source
# File lib/kanji_master/converter.rb, line 21
def hiragana(text); hira(text) end
kana(text) click to toggle source
# File lib/kanji_master/converter.rb, line 11
def kana(text)
  if text.match(RegexConstant::HIRAGANA_REGEX)
    NKF.nkf("--katakana -Ww", text)
  elsif text.match(RegexConstant::KATAKANA_REGEX)
    text
  elsif text.match(RegexConstant::ROMAJI_REGEX)
    Romaji.romaji2kana text
  end
end
katakana(text) click to toggle source
# File lib/kanji_master/converter.rb, line 10
def katakana(text); kana(text) end