Class: Verbs::Conjugator::Conjugations

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/verbs/conjugator.rb

Overview

This class determines the conjugations from the given options (or defaults) conjugations are then applied to the verb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConjugations

Creates initial variables for class



28
29
30
31
32
# File 'lib/verbs/conjugator.rb', line 28

def initialize
  @irregulars = {}
  @single_terminal_consonants = []
  @copulars = {}
end

Instance Attribute Details

#copularsObject (readonly)

permit outside functions access to these variables



25
26
27
# File 'lib/verbs/conjugator.rb', line 25

def copulars
  @copulars
end

#irregularsObject (readonly)

permit outside functions access to these variables



25
26
27
# File 'lib/verbs/conjugator.rb', line 25

def irregulars
  @irregulars
end

#single_terminal_consonantsObject (readonly)

permit outside functions access to these variables



25
26
27
# File 'lib/verbs/conjugator.rb', line 25

def single_terminal_consonants
  @single_terminal_consonants
end

Instance Method Details

#irregular(infinitive, preterite = nil, past_participle = nil, &blk) ⇒ Object

Determines irregular verbs from the expression Params:

  • infinitive, the given verb

  • preterite, denote events that took place in the past

  • past_participle, form of a verb, ending in ‘ed’

  • &blk, block of code that may be run



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

def irregular(infinitive, preterite = nil, past_participle = nil, &blk)
  if block_given?
    # create new Verb object with infinitive and &blk
    irregular = ::Verbs::Verb.new infinitive, &blk
  else
    unless preterite && past_participle
      raise ArgumentError,
            'Standard irregular verbs must specify preterite and past participle forms'
    end

    # create new Verb object with infinitive, preterite and past_participle
    irregular = ::Verbs::Verb.new infinitive, preterite: preterite, past_participle: past_participle
  end
  @irregulars[infinitive] = irregular
end

#single_terminal_consonant(infinitive) ⇒ Object

Find single terminal consonant with the infinitive Params:

  • infinitive, the given verb



59
60
61
# File 'lib/verbs/conjugator.rb', line 59

def single_terminal_consonant(infinitive)
  @single_terminal_consonants << infinitive
end