class ClinicFinder::GestationHelper
Attributes
gestational_age[R]
gestational_weeks[R]
Public Class Methods
new(gestational_age)
click to toggle source
# 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
Public Instance Methods
gestational_tier()
click to toggle source
# 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)
click to toggle source
# File lib/clinic_finder/gestation_helper.rb, line 28 def within_gestational_limit?(gestational_limit) @gestational_age < gestational_limit end