class SingaporeCPFCalculator::AgeGroup
The contribution rates in respect of an employee above 35, 50, 55, 60 or 65 years of age shall be applied from the first day of the month after the month of his 35th, 50th, 55th, 60th or 65th birthday.
Attributes
birthdate[R]
current_date[R]
Public Class Methods
get(current_date, birthdate:)
click to toggle source
@param [Date] current_date
@param [Date] birthdate @return [Symbol] the symbol representation of the age group
- :group_50_years_and_below - :group_55_years_and_below - :group_above_50_to_55_years - :group_above_55_to_60_years - :group_above_60_to_65_years - :group_above_65_years
# File lib/singapore_cpf_calculator/age_group.rb, line 19 def get(current_date, birthdate:) new(current_date, birthdate: birthdate).get end
new(current_date, birthdate:)
click to toggle source
@param [Date] current_date
@param [Date] birthdate:
# File lib/singapore_cpf_calculator/age_group.rb, line 26 def initialize(current_date, birthdate:) @current_date = current_date @birthdate = birthdate end
Public Instance Methods
get()
click to toggle source
@return [Symbol] the symbol representation of the age group
- :group_50_years_and_below - :group_55_years_and_below - :group_above_50_to_55_years - :group_above_55_to_60_years - :group_above_60_to_65_years - :group_above_65_years
# File lib/singapore_cpf_calculator/age_group.rb, line 38 def get if current_date.year <= 2015 age_grouping_for_2015_and_earlier else age_grouping_for_2016_and_later end end
Private Instance Methods
age()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 50 def age @age ||= effective_age end
age_grouping_for_2015_and_earlier()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 64 def age_grouping_for_2015_and_earlier case when age < 50 :group_50_years_and_below when 50 <= age && age < 55 :group_above_50_to_55_years when 55 <= age && age < 60 :group_above_55_to_60_years when 60 <= age && age < 65 :group_above_60_to_65_years else # 65 <= age :group_above_65_years end end
age_grouping_for_2016_and_later()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 79 def age_grouping_for_2016_and_later case when age < 55 :group_55_years_and_below when 55 <= age && age < 60 :group_above_55_to_60_years when 60 <= age && age < 65 :group_above_60_to_65_years else # 65 <= age :group_above_65_years end end
effective_age()
click to toggle source
# File lib/singapore_cpf_calculator/age_group.rb, line 54 def effective_age age_by_year = current_date.year - birthdate.year if current_date.month > birthdate.month age_by_year else age_by_year - 1 end end