Class: Csvtool::Interface::CLI::Output::TableRenderer
- Inherits:
-
Object
- Object
- Csvtool::Interface::CLI::Output::TableRenderer
- Defined in:
- lib/csvtool/interface/cli/output/table_renderer.rb
Constant Summary collapse
- MIN_COLUMN_WIDTH =
4
Instance Method Summary collapse
Instance Method Details
#render(headers:, rows:, max_width: 80) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/csvtool/interface/cli/output/table_renderer.rb', line 10 def render(headers:, rows:, max_width: 80) widths = compute_widths(headers, rows) widths = fit_widths(widths, max_width) lines = [] lines << format_row(headers, widths) lines << separator(widths) rows.each { |row| lines << format_row(row, widths) } lines.join("\n") end |