Class: SingaporeCPFCalculator::CPFContribution

Inherits:
Object
  • Object
show all
Defined in:
lib/singapore_cpf_calculator/cpf_contribution.rb

Overview

Result object that describes the total, employee, and employer contribution.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total:, employee:) ⇒ CPFContribution

Returns a new instance of CPFContribution.

Parameters:

  • total (BigDecimal)

    the total contribution amount

  • employee (BigDecimal)

    the employee contribution amount



11
12
13
14
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 11

def initialize(total:, employee:)
  @total = total
  @employee = employee
end

Instance Attribute Details

#employeeBigDecimal (readonly)

Returns:

  • (BigDecimal)


7
8
9
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 7

def employee
  @employee
end

#totalBigDecimal (readonly)

Returns:

  • (BigDecimal)


7
8
9
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 7

def total
  @total
end

Instance Method Details

#==(other) ⇒ TrueClass, FalseClass

Parameters:

Returns:

  • (TrueClass, FalseClass)


23
24
25
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 23

def ==(other)
  total == other.total && employee == other.employee
end

#employerBigDecimal

Returns difference between the total and employee contributions.

Returns:

  • (BigDecimal)

    difference between the total and employee contributions



17
18
19
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 17

def employer
  @employer ||= total - employee
end