Module: OldKana

Included in:
String
Defined in:
lib/old_kana.rb,
lib/old_kana/version.rb

Constant Summary collapse

OLD_KANA_TO_GENDAI_KANA =
{ "" => "", "" => "", "" => "", "" => "", "" => "", "" => "", "" => "",
"" => "", "" => "" }
VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#to_gendaikanaObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/old_kana.rb', line 11

def to_gendaikana
  replaced = gsub(/(?<!^)[はひふへほ]/) { |old_kana| OLD_KANA_TO_GENDAI_KANA[old_kana] }
             .gsub(/[ゐゑぢづ]/) { |old_kana| OLD_KANA_TO_GENDAI_KANA[old_kana] }
             .gsub(/\bを\b/, "")
             .gsub(/くわ/, "")
             .gsub(/ぐわ/, "")
             .gsub(/(?<!^)む/, "")

  replaced.to_roman
          .gsub(/shi/, "si")
          .gsub(/au/, "ou")
          .gsub(/iu/, "yuu")
          .gsub(/eu|ehu/, "you")
          .roman_to_hiragana
          .tr("n", "")
end