Module: Verbs::Conjugator
Defined Under Namespace
Classes: Conjugations
Instance Method Summary collapse
-
#conjugate(infinitive, options = {}) ⇒ Object
Using options given, determine the conjugation and the subject Return the subject, if there is one, and the proper conjugation Params: * infinitive, the given verb * options, the list of parameters to alter the conjugation.
-
#conjugations ⇒ Object
Runs a block of code if given in a class instance else only class instance is created.
-
#subject(options) ⇒ Object
Finds the pronoun associated with the subject for the conjugation Returns the pronoun Params: * options, list of options given to determine conjugation.
Instance Method Details
#conjugate(infinitive, options = {}) ⇒ Object
Using options given, determine the conjugation and the subject Return the subject, if there is one, and the proper conjugation Params:
-
infinitive, the given verb
-
options, the list of parameters to alter the conjugation
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/verbs/conjugator.rb', line 79 def conjugate(infinitive, = {}) infinitive = infinitive.dup if infinitive.is_a?(String) # set all options according to parameter, or the default tense = [:tense] || :present # present, past, future person = [:person] || :third # first, second, third plurality = [:plurality] || :singular # singular, plural diathesis = [:diathesis] || :active # active, passive mood = [:mood] || :indicative # imperative, subjunctive aspect = [:aspect] || default_aspect() # perfective, habitual, progressive, perfect, prospective check_for_improper_constructions(infinitive, tense, person, mood, diathesis) # find incompatabilities form = form_for(tense, aspect, diathesis) # find form array based on tense and aspect # map form array to conjugation array, applying infinitive and options to the array conjugation = form.map { |e| resolve e, infinitive, tense, person, plurality, mood }.join(' ').strip if [:subject] # When options includes a subject, actor = .delete(:subject) # remove from options and make subject humanized actor = subject().humanize if actor.is_a?(TrueClass) end "#{actor} #{conjugation}".strip end |
#conjugations ⇒ Object
Runs a block of code if given in a class instance else only class instance is created
66 67 68 69 70 71 72 |
# File 'lib/verbs/conjugator.rb', line 66 def conjugations if block_given? yield Conjugations.instance else Conjugations.instance end end |
#subject(options) ⇒ Object
Finds the pronoun associated with the subject for the conjugation Returns the pronoun Params:
-
options, list of options given to determine conjugation
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/verbs/conjugator.rb', line 108 def subject() case [[:person], [:plurality]] when %i[first singular] 'I' when %i[first plural] 'we' when %i[second singular], %i[second plural] 'you' when %i[third singular] 'he' when %i[third plural] 'they' end end |