Class: Amortizy::ConsoleFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/amortizy/console_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(schedule_obj) ⇒ ConsoleFormatter

Returns a new instance of ConsoleFormatter.



5
6
7
8
# File 'lib/amortizy/console_formatter.rb', line 5

def initialize(schedule_obj)
  @schedule_obj = schedule_obj
  @data = schedule_obj.schedule
end

Instance Method Details

#renderObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/amortizy/console_formatter.rb', line 10

def render
  puts header
  puts '-' * 195

  @data.each do |row|
    puts row[:payment_type] == 'Grace Period' ? grace_row(row) : payment_row(row)
  end

  print_summary
end