Sha256: 37b07c7721e705d5835010fec160773e77416193ec01401510c63ad90705b470
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Katsuyoujin class Base attr_reader :verb, :base_letter ICHIDAN_BASE_TABLE = YAML.load_file 'rules/ichidan/base.yml' GODAN_BASE_TABLE = YAML.load_file 'rules/godan/base.yml' def initialize(verb, base_letter) @verb = verb @base_letter = base_letter end def conjugate(category: nil, hiragana: true) case category || verb.category when 'ichidan' then ichidan_base(verb, base_letter, hiragana: hiragana) when 'godan' then godan_base(verb, base_letter, hiragana: hiragana) when 'irregular' then irregular_base(verb, base_letter, hiragana: hiragana) end end def ichidan_base(verb, base_letter, hiragana: true) verb_root(hiragana) + ICHIDAN_BASE_TABLE[base_letter] end def godan_base(verb, base_letter, hiragana: true) verb_root(hiragana) + GODAN_BASE_TABLE[base_letter][verb.ending] end def irregular_base(verb, base_letter, hiragana: true) fail NotImplementedError end def verb_root(hiragana = true) hiragana ? verb.hiragana_root : verb.root end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katsuyoujin-0.0.1.1 | lib/katsuyoujin/base.rb |