Class: Renalware::AutomaticAgeCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/renalware/automatic_age_calculator.rb

Instance Method Summary collapse

Constructor Details

#initialize(age, born_on:, age_on_date:) ⇒ AutomaticAgeCalculator

Returns a new instance of AutomaticAgeCalculator.



7
8
9
10
11
# File 'lib/renalware/automatic_age_calculator.rb', line 7

def initialize(age, born_on:, age_on_date:)
  @age = age
  @born_on = born_on
  @age_on_date = age_on_date
end

Instance Method Details

#computeObject



13
14
15
16
17
18
19
20
# File 'lib/renalware/automatic_age_calculator.rb', line 13

def compute
  if @born_on.present?
    parts = AgeCalculator.new.compute(@born_on, @age_on_date)
    Age.new_from(parts)
  else
    @age
  end
end