Sha256: c8e829191953f7c2100158988ddb098317f8cce24910362b6737bc9628408c2c
Contents?: true
Size: 1.12 KB
Versions: 6
Compression:
Stored size: 1.12 KB
Contents
module SingaporeCPFCalculator class SPRStatus class << self def get(current_date, status_start_date:) new(current_date, status_start_date: status_start_date).get end end def initialize(current_date, status_start_date:) @current_date = current_date @status_start_date = status_start_date end def get case when spr1_start <= current_date && current_date <= spr1_end then :SPR1 when spr2_start <= current_date && current_date <= spr2_end then :SPR2 when spr3_start <= current_date then :SPR3 else nil # could not be determined end end private attr_reader :current_date, :status_start_date def spr1_start status_start_date end def spr1_end @spr1_end ||= (spr1_start.beginning_of_month.advance years: 1).end_of_month end def spr2_start @spr2_start ||= spr1_end.beginning_of_month.advance months: 1 end def spr2_end @spr2_end ||= spr2_start.dup.advance(months: 11).end_of_month end def spr3_start spr2_end.beginning_of_month.advance(months: 1) end end end
Version data entries
6 entries across 6 versions & 1 rubygems