Class: BaseFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/arabic_conjugator/factories/base_factory.rb

Constant Summary collapse

FORM_MAPPING =
{
  "1past" => FormIPastBase,
  "2past" => FormIIPastBase,
  "3past" => FormIIIPastBase,
  "4past" => FormIVPastBase,
  "5past" => FormVPastBase,
  "6past" => FormVIPastBase,
  "7past" => FormVIIPastBase,
  "8past" => FormVIIIPastBase,
  "10past" => FormXPastBase,
  "1present" => FormIPresentBase,
  "2present" => FormIIPresentBase,
  "3present" => FormIIIPresentBase,
  "4present" => FormIVPresentBase,
  "5present" => FormVPresentBase,
  "6present" => FormVIPresentBase,
  "7present" => FormVIIPresentBase,
  "8present" => FormVIIIPresentBase,
  "10present" => FormXPresentBase
}

Instance Method Summary collapse

Constructor Details

#initialize(verb) ⇒ BaseFactory

Returns a new instance of BaseFactory.



43
44
45
46
47
48
# File 'lib/arabic_conjugator/factories/base_factory.rb', line 43

def initialize(verb)
  @verb = verb
  @form_name = verb.form
  @tense = verb.opts[:tense]
  @types = verb.types[0]
end

Instance Method Details

#load_baseObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/arabic_conjugator/factories/base_factory.rb', line 50

def load_base
  form = FORM_MAPPING[@form_name.concat(@tense)].new(@verb)
  case @types
  when "assimilated defective"
    form.assimilated_defective_base
  when "hollow defective"
    form.hollow_defective_base
  when "assimilated"
    form.assimilated_base
  when "defective"
    form.defective_base
  when "hollow"
    form.hollow_base
  when "doubled"
    form.doubled_base
  when "regular"
    form.regular_base
  when "assimilated_taa"
    form.assimilated_taa_base
  when "morphed_taa"
    form.morphed_taa_base
  end
end