diff --git a/lib/verb.rb b/lib/verb.rb index 2fd2f5f..b121cab 100644 --- a/lib/verb.rb +++ b/lib/verb.rb @@ -61,18 +61,22 @@ class Verb dict end + def long_form_present_positive + stem + "ます" + end + + def long_form_present_negative + stem + "ません" + end + def short_form_present_positive dictionary end end class IchidanVerb < Verb - def long_form_present_positive - all_but_last_character + "ます" - end - - def long_form_present_negative - all_but_last_character + "ません" + def stem + all_but_last_character end def short_form_present_negative @@ -85,12 +89,12 @@ class IchidanVerb < Verb end class GodanVerb < Verb - def long_form_present_positive - all_but_last_character + last_character("i") + "ます" + def iku? + dict.kanji == "行く" end - def long_form_present_negative - all_but_last_character + last_character("i") + "ません" + def stem + all_but_last_character + last_character("i") end def short_form_present_negative @@ -98,26 +102,26 @@ class GodanVerb < Verb end def te - case last_character - when "う" - all_but_last_character + "って" - when "る" - all_but_last_character + "って" - when "つ" - all_but_last_character + "って" - when "す" - all_but_last_character + "して" - when "く" - all_but_last_character + "いて" - when "ぐ" - all_but_last_character + "いで" - when "ぶ" - all_but_last_character + "んで" - when "む" - all_but_last_character + "んで" - when "ぬ" - all_but_last_character + "んで" - end + all_but_last_character + case last_character + when "う" + "って" + when "る" + "って" + when "つ" + "って" + when "す" + "して" + when "く" + iku? ? "って" : "いて" + when "ぐ" + "いで" + when "ぶ" + "んで" + when "む" + "んで" + when "ぬ" + "んで" + end end end @@ -126,12 +130,8 @@ class SuruVerb < Verb dict[..-3] end - def long_form_present_positive - prefix + "します" - end - - def long_form_present_negative - prefix + "しません" + def stem + prefix + "し" end def short_form_present_negative diff --git a/test/test_verb.rb b/test/test_verb.rb index c2770c1..1509a13 100644 --- a/test/test_verb.rb +++ b/test/test_verb.rb @@ -5,6 +5,16 @@ class TestVerb < Minitest::Test def setup @miru = IchidanVerb.new("見る", "みる", "to look") @nomu = GodanVerb.new("飲む", "のむ", "to drink") + @au = GodanVerb.new("会う", "あう", "to meet") + @matsu = GodanVerb.new("待つ", "まつ", "to wait") + @toru = GodanVerb.new("取る", "とる", "to take") + @yomu = GodanVerb.new("読む", "よむ", "to read") + @asobu = GodanVerb.new("遊ぶ", "あそぶ", "to play") + @shinu = GodanVerb.new("死ぬ", "しぬ", "to die") + @kaku = GodanVerb.new("書く", "かく", "to write") + @iku = GodanVerb.new("行く", "いく", "to go") + @oyogu = GodanVerb.new("泳ぐ", "およぐ", "to swim") + @hanasu = GodanVerb.new("話す", "はなす", "to speak") @suru = SuruVerb.new("する", "する", "to do") @benkyousuru = SuruVerb.new("勉強する", "べんきょうする", "to study") end @@ -18,6 +28,16 @@ class TestVerb < Minitest::Test assert_equal "して", @suru.te.kana assert_equal "勉強して", @benkyousuru.te.kanji assert_equal "べんきょうして", @benkyousuru.te.kana + assert_equal "会って", @au.te.kanji + assert_equal "待って", @matsu.te.kanji + assert_equal "取って", @toru.te.kanji + assert_equal "読んで", @yomu.te.kanji + assert_equal "遊んで", @asobu.te.kanji + assert_equal "死んで", @shinu.te.kanji + assert_equal "書いて", @kaku.te.kanji + assert_equal "行って", @iku.te.kanji + assert_equal "泳いで", @oyogu.te.kanji + assert_equal "話して", @hanasu.te.kanji end def test_long_form_present_positive