Class: Formulas::LoanPrincipalCalculator
- Inherits:
-
Object
- Object
- Formulas::LoanPrincipalCalculator
- Defined in:
- lib/formulas/loan_principal_calculator.rb
Instance Attribute Summary collapse
-
#apr ⇒ Object
Returns the value of attribute apr.
-
#months ⇒ Object
Returns the value of attribute months.
-
#repayment ⇒ Object
Returns the value of attribute repayment.
Instance Method Summary collapse
Instance Attribute Details
#apr ⇒ Object
Returns the value of attribute apr.
5 6 7 |
# File 'lib/formulas/loan_principal_calculator.rb', line 5 def apr @apr end |
#months ⇒ Object
Returns the value of attribute months.
5 6 7 |
# File 'lib/formulas/loan_principal_calculator.rb', line 5 def months @months end |
#repayment ⇒ Object
Returns the value of attribute repayment.
5 6 7 |
# File 'lib/formulas/loan_principal_calculator.rb', line 5 def repayment @repayment end |
Instance Method Details
#divide_by ⇒ Object
7 8 9 |
# File 'lib/formulas/loan_principal_calculator.rb', line 7 def divide_by interest_with_principal - 1 end |
#interest_with_principal ⇒ Object
11 12 13 |
# File 'lib/formulas/loan_principal_calculator.rb', line 11 def interest_with_principal (1 + (apr / 12)) ** months end |
#principal ⇒ Object
15 16 17 |
# File 'lib/formulas/loan_principal_calculator.rb', line 15 def principal (((repayment * divide_by) / interest_with_principal) * 12 ) / apr end |