Class: Csvtool::Interface::CLI::Output::Formatters::StatsFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/csvtool/interface/cli/output/formatters/stats_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_renderer:) ⇒ StatsFormatter

Returns a new instance of StatsFormatter.



11
12
13
# File 'lib/csvtool/interface/cli/output/formatters/stats_formatter.rb', line 11

def initialize(table_renderer:)
  @table_renderer = table_renderer
end

Instance Method Details

#call(data:, format:, max_width: 80) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/csvtool/interface/cli/output/formatters/stats_formatter.rb', line 15

def call(data:, format:, max_width: 80)
  case format
  when "json"
    JSON.generate(data)
  when "csv"
    csv_lines(data).join("\n")
  else
    text_lines(data, max_width: max_width).join("\n")
  end
end