Module: Traduce

Defined in:
lib/traduce.rb,
lib/traduce/version.rb

Defined Under Namespace

Classes: Verb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.conjugate(verb, person:, number: 1, tense: :present, mood: :indictive, voice: :active) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/traduce.rb', line 5

def self.conjugate(verb, person:, number: 1, tense: :present, mood: :indictive, voice: :active)
  verb = Verb.new(verb) unless verb.is_a? Verb
  verb.gsub(/([e|a|i])r\Z/) do |m|
    ending = verb.ar? ? "a" : "e"
    suffix = person.eql?(3) ? "#{ending}" : "#{ending}s"
    person.eql?(1) ? "o" : suffix
  end
end