Class: Bankroll::AmortizationSchedule

Inherits:
Object
  • Object
show all
Extended by:
Callable, Dry::Initializer
Defined in:
lib/bankroll/amortization_schedule.rb

Defined Under Namespace

Classes: Payment

Instance Method Summary collapse

Instance Method Details

#callObject



39
40
41
# File 'lib/bankroll/amortization_schedule.rb', line 39

def call
  self
end

#eachObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bankroll/amortization_schedule.rb', line 21

def each
  Enumerator.new do |yielder|
    current_payment = Payment.new(
      payment: monthly_payment.round,
      total_interest: Decimal["0"],
      balance: @present_value
    )

    periods.times do |period|
      yielder << current_payment = payment_for_period(period, current_payment)
    end
  end
end

#paymentsObject



35
36
37
# File 'lib/bankroll/amortization_schedule.rb', line 35

def payments
  @payments ||= each.to_a
end