Module: Formulas::StudentLoanRepayment
- Defined in:
- lib/formulas/student_loan_repayment.rb,
lib/formulas/student_loan_repayment/repayment_base.rb,
lib/formulas/student_loan_repayment/fix_repayment_per_period.rb,
lib/formulas/student_loan_repayment/percent_repayment_per_threshold.rb
Overview
Provide calculation to work out student loan repayment in frequency loan = StudentLoan.new(salary_amount: 1000, salary_frequency: Income::Salary::WEEKLY)
loan.repayment
> <#ConstantPerPeriod>
loan.repayment
> 317
Defined Under Namespace
Classes: FixRepaymentPerPeriod, PercentRepaymentPerThreshold, RepaymentBase
Instance Attribute Summary collapse
-
#repayment ⇒ Object
readonly
Returns the value of attribute repayment.
Instance Method Summary collapse
Instance Attribute Details
#repayment ⇒ Object (readonly)
Returns the value of attribute repayment.
21 22 23 |
# File 'lib/formulas/student_loan_repayment.rb', line 21 def repayment @repayment end |
Instance Method Details
#initialize(income_strategy:, repayment_strategy:, rates:) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/formulas/student_loan_repayment.rb', line 23 def initialize(income_strategy: , repayment_strategy:, rates:) raise 'Missing required salary' unless income_strategy raise 'Missing required repayment rates' unless rates raise 'Missing required repayment strategy' unless repayment_strategy @repayment = repayment_strategy.new(salary: income_strategy, repayment: rates) end |