Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Baby Steps.

  • Loading branch information...
commit 9d89bd958fae9d6cd178d8eeba4923820d715c64 1 parent d9fc461
@ledewitt authored
View
13 home_payment_calc/bin/payment_report
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby -w
+
+require_relative "../lib/home_payment_calc"
+
+calculator = HomePaymentCalculator::Calculator.new( ARGV[0].to_f,
+ ARGV[1].to_f,
+ ARGV[2].to_i )
+
+report = HomePaymentCalculator::Payment_Report.new(calculator)
+
+report.each_with_index do |i|
+ puts "%3d: %s" % [i + 1]
+end
View
18 home_payment_calc/lib/home_payment_calc/payment_report.rb
@@ -1,12 +1,22 @@
module HomePaymentCalculator
class Payment_Report
+ include Enumerable
- def initialize
- @loan = Calculator.new(250000, 0.05, 30)
+ def initialize(calculator)
+ @calculator=calculator
end
- def monthly_payment
- puts "Monthly principle #{@loan.monthly_prin_payment}; Monthly interest #{@loan.monthly_int_payment}"
+ attr_reader :calculator
+
+ def monthly_payment(month)
+ interest, principle = calculator.interest_and_principle_for_month(month)
+ end
+
+ def each
+ (1..calculator.months).each do |month|
+ yield monthly_payment(month)
+ #following code to be deleted
end
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.