Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion lib/romanize.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
module Romanize
def romanize(s)
def romanize(hiragana)
result = ""
hiragana.split(//).each_with_index do |h, i|
result.chop if ['ゃ','ゅ','ょ'].include?(h)
result << convert_character(h) # if h != "っ"
end
result
end

def convert_character(char)
character_hash = {
"あ"=>"a","い"=>"i","う"=>"u","え"=>"e","お"=>"o",
# ひらがな
"ひ" => "hi", "ら" => "ra", "が" => "ga", "な" => "na",
# 新宿
"し" => "si","ん"=>"n","じ"=>"z",
# "ゅ" => "yu",
"く"=>"ku",
# 納豆
"な" => "na","っ"=>"t","と"=>"to","う"=>"u",
"ゃ"=>"ya","ゅ"=>"yu","ょ"=>"yo"
}
character_hash[char]
end

def convert_tu(after_char)

end
end