Class: ClinicFinder::GestationHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/clinic_finder/gestation_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gestational_age) ⇒ GestationHelper

Returns a new instance of GestationHelper.



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

def initialize(gestational_age)
  @gestational_age = gestational_age
  # BUSINESS LOGIC HERE - CHANGE AS NEEDED
  # We round up under the assumption that as soon as you pass the threshhold
  # of a pricing tier - say, 9 weeks and 1 day - you will be priced into the
  # more expensive tier (12 weeks). Change logic if this is not the case.
  @gestational_weeks = (@gestational_age/7.0).ceil
end

Instance Attribute Details

#gestational_ageObject (readonly)

Returns the value of attribute gestational_age.



3
4
5
# File 'lib/clinic_finder/gestation_helper.rb', line 3

def gestational_age
  @gestational_age
end

#gestational_weeksObject (readonly)

Returns the value of attribute gestational_weeks.



3
4
5
# File 'lib/clinic_finder/gestation_helper.rb', line 3

def gestational_weeks
  @gestational_weeks
end

Instance Method Details

#gestational_tierObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/clinic_finder/gestation_helper.rb', line 14

def gestational_tier
  if @gestational_weeks < 10
    'costs_9wks'
  elsif @gestational_weeks < 13
    'costs_12wks'
  elsif @gestational_weeks < 19
    'costs_18wks'
  elsif @gestational_weeks < 25
    'costs_24wks'
  else
    'costs_30wks'
  end
end

#within_gestational_limit?(gestational_limit) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/clinic_finder/gestation_helper.rb', line 28

def within_gestational_limit?(gestational_limit)
  @gestational_age < gestational_limit
end