Module: Aspera::Cli::TableFitter
- Defined in:
- lib/aspera/cli/table_fitter.rb
Overview
Build a terminal table that fits in a given width, by wrapping cells.
Columns with text (containing spaces, e.g. description) are wrapped first, the widest first.
If not enough, other columns (names, identifiers) are wrapped too.
If the table cannot fit, columns are narrowed to their minimum width.
Class Method Summary collapse
Class Method Details
.table(headings:, rows:, style:, width:) ⇒ Terminal::Table
36 37 38 39 |
# File 'lib/aspera/cli/table_fitter.rb', line 36 def table(headings:, rows:, style:, width:) headings, rows = fit(headings, rows, width - overhead(headings.length, style)) unless width.nil? Terminal::Table.new(headings: headings, rows: rows, style: style) end |