Class: SingaporeCPFCalculator::CPFContribution
- Inherits:
-
Object
- Object
- SingaporeCPFCalculator::CPFContribution
- Defined in:
- lib/singapore_cpf_calculator/cpf_contribution.rb
Overview
Result object that describes the total, employee, and employer contribution.
Instance Attribute Summary collapse
- #aw_subject_to_cpf ⇒ BigDecimal readonly
- #employee ⇒ BigDecimal readonly
- #ow_subject_to_cpf ⇒ BigDecimal readonly
- #total ⇒ BigDecimal readonly
Instance Method Summary collapse
- #==(other) ⇒ TrueClass, FalseClass
-
#employer ⇒ BigDecimal
Difference between the total and employee contributions.
-
#initialize(total:, employee:, ow_subject_to_cpf:, aw_subject_to_cpf:) ⇒ CPFContribution
constructor
A new instance of CPFContribution.
- #inspect ⇒ Object
Constructor Details
#initialize(total:, employee:, ow_subject_to_cpf:, aw_subject_to_cpf:) ⇒ CPFContribution
Returns a new instance of CPFContribution.
13 14 15 16 17 18 |
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 13 def initialize(total:, employee:, ow_subject_to_cpf:, aw_subject_to_cpf:) @total = total @employee = employee @ow_subject_to_cpf = ow_subject_to_cpf @aw_subject_to_cpf = aw_subject_to_cpf end |
Instance Attribute Details
#aw_subject_to_cpf ⇒ BigDecimal (readonly)
7 8 9 |
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 7 def aw_subject_to_cpf @aw_subject_to_cpf end |
#employee ⇒ BigDecimal (readonly)
7 8 9 |
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 7 def employee @employee end |
#ow_subject_to_cpf ⇒ BigDecimal (readonly)
7 8 9 |
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 7 def ow_subject_to_cpf @ow_subject_to_cpf end |
#total ⇒ BigDecimal (readonly)
7 8 9 |
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 7 def total @total end |
Instance Method Details
#==(other) ⇒ TrueClass, FalseClass
27 28 29 30 31 |
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 27 def ==(other) other.kind_of?(CPFContribution) && total == other.total && employee == other.employee && (ow_subject_to_cpf == other.ow_subject_to_cpf) && (aw_subject_to_cpf == other.aw_subject_to_cpf) end |
#employer ⇒ BigDecimal
Returns difference between the total and employee contributions.
21 22 23 |
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 21 def employer @employer ||= total - employee end |
#inspect ⇒ Object
33 34 35 36 |
# File 'lib/singapore_cpf_calculator/cpf_contribution.rb', line 33 def inspect {total: total.to_s, employee: employee.to_s, ow_subject_to_cpf: ow_subject_to_cpf.to_s, aw_subject_to_cpf: aw_subject_to_cpf.to_s}.to_json end |