Class: MortgageCalc::MortgageUtil
- Inherits:
-
Object
- Object
- MortgageCalc::MortgageUtil
- Defined in:
- lib/mortgage_calc/mortgage_util.rb
Instance Attribute Summary collapse
-
#borrowed_fees ⇒ Object
Returns the value of attribute borrowed_fees.
-
#fee ⇒ Object
Returns the value of attribute fee.
-
#interest_rate ⇒ Object
Returns the value of attribute interest_rate.
-
#loan_amount ⇒ Object
Returns the value of attribute loan_amount.
-
#period ⇒ Object
Returns the value of attribute period.
Instance Method Summary collapse
- #apr ⇒ Object
-
#initialize(loan_amount, interest_rate, fee, period = 360, borrowed_fees = 0) ⇒ MortgageUtil
constructor
A new instance of MortgageUtil.
- #monthly_payment ⇒ Object
Constructor Details
#initialize(loan_amount, interest_rate, fee, period = 360, borrowed_fees = 0) ⇒ MortgageUtil
Returns a new instance of MortgageUtil.
5 6 7 8 9 10 11 |
# File 'lib/mortgage_calc/mortgage_util.rb', line 5 def initialize(loan_amount, interest_rate, fee, period=360, borrowed_fees=0) self.loan_amount = Float(loan_amount.to_s) self.interest_rate = Float(interest_rate.to_s) self.period = Integer(period.to_s) self.fee = Float(fee.to_s) self.borrowed_fees = Float(borrowed_fees.to_s) end |
Instance Attribute Details
#borrowed_fees ⇒ Object
Returns the value of attribute borrowed_fees.
3 4 5 |
# File 'lib/mortgage_calc/mortgage_util.rb', line 3 def borrowed_fees @borrowed_fees end |
#fee ⇒ Object
Returns the value of attribute fee.
3 4 5 |
# File 'lib/mortgage_calc/mortgage_util.rb', line 3 def fee @fee end |
#interest_rate ⇒ Object
Returns the value of attribute interest_rate.
3 4 5 |
# File 'lib/mortgage_calc/mortgage_util.rb', line 3 def interest_rate @interest_rate end |
#loan_amount ⇒ Object
Returns the value of attribute loan_amount.
3 4 5 |
# File 'lib/mortgage_calc/mortgage_util.rb', line 3 def loan_amount @loan_amount end |
#period ⇒ Object
Returns the value of attribute period.
3 4 5 |
# File 'lib/mortgage_calc/mortgage_util.rb', line 3 def period @period end |
Instance Method Details
#apr ⇒ Object
13 14 15 |
# File 'lib/mortgage_calc/mortgage_util.rb', line 13 def apr @apr ||= calculate_apr end |
#monthly_payment ⇒ Object
17 18 19 |
# File 'lib/mortgage_calc/mortgage_util.rb', line 17 def monthly_payment @monthly_payment ||= calculate_monthly_payment(self.loan_amount + self.borrowed_fees, monthly_interest_rate, self.period) end |