Module: Verbs::Conjugator

Extended by:
Conjugator
Included in:
Conjugator
Defined in:
lib/verbs/conjugator.rb

Defined Under Namespace

Classes: Conjugations

Instance Method Summary collapse

Instance Method Details

#conjugate(infinitive, options = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/verbs/conjugator.rb', line 37

def conjugate(infinitive, options = {})
  tense = options[:tense] ||         :present    # present, past, future
  person = options[:person] ||       :third      # first, second, third
  plurality = options[:plurality] || :singular   # singular, plural
  diathesis = options[:diathesis] || :active     # active, passive
  mood = options[:mood] ||           :indicative # imperative, subjunctive
  aspect = options[:aspect] ||       :habitual   # perfective, habitual, progressive, perfect, prospective
  
  check_for_improper_constructions(tense, person, mood)
  
  form = form_for(tense, aspect)

  conjugation = form.map { |e| resolve e, infinitive, tense, person, plurality, mood }.join(' ').strip

  if options[:subject]
    actor = options.delete(:subject)
    actor = subject(options).humanize if actor.is_a?(TrueClass)
  end

  "#{actor} #{conjugation}".strip
end

#conjugationsObject



29
30
31
32
33
34
35
# File 'lib/verbs/conjugator.rb', line 29

def conjugations
  if block_given?
    yield Conjugations.instance
  else
    Conjugations.instance
  end
end

#subject(options) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/verbs/conjugator.rb', line 59

def subject(options)
  case [options[:person], options[:plurality]]
  when [:first, :singular]
    'I'
  when [:first, :plural]
    'we'
  when [:second, :singular], [:second, :plural]
    'you'
  when [:third, :singular]
    'he'
  when [:third, :plural]
    'they'
  end
end