Class: HledgerForecast::SummarizerFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/hledger_forecast/summarizer_formatter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.format(output, settings) ⇒ Object



3
4
5
# File 'lib/hledger_forecast/summarizer_formatter.rb', line 3

def self.format(output, settings)
  new.format(output, settings)
end

Instance Method Details

#format(output, settings) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/hledger_forecast/summarizer_formatter.rb', line 7

def format(output, settings)
  @table = Terminal::Table.new
  @settings = settings

  init_table

  if @settings.roll_up.nil?
    add_rows_to_table(output)
    add_total_row_to_table(output, :amount)
  else
    add_rolled_up_rows_to_table(output)
    add_total_row_to_table(output, :rolled_up_amount)
  end

  @table
end