Class: Hashira::Report::Columns
- Inherits:
-
Object
- Object
- Hashira::Report::Columns
- Defined in:
- lib/hashira/report/columns.rb
Constant Summary collapse
- CAP =
48- HEAD =
23- GAP =
" "- NUMBER =
/\A-?\d+(?:\.\d+)?\z/
Instance Method Summary collapse
- #body ⇒ Object
- #header ⇒ Object
-
#initialize(headers, rows, io: $stdout) ⇒ Columns
constructor
A new instance of Columns.
- #print ⇒ Object
- #rule ⇒ Object
Constructor Details
#initialize(headers, rows, io: $stdout) ⇒ Columns
Returns a new instance of Columns.
9 10 11 12 |
# File 'lib/hashira/report/columns.rb', line 9 def initialize(headers, rows, io: $stdout) @headers, *@rows = [headers, *rows].map { |cells| cells.map { clip(it) } } @io = io end |
Instance Method Details
#body ⇒ Object
20 |
# File 'lib/hashira/report/columns.rb', line 20 def body = @rows.each { @io.puts(line(it)) } |
#header ⇒ Object
22 |
# File 'lib/hashira/report/columns.rb', line 22 def header = line(@headers) |
#print ⇒ Object
14 15 16 17 18 |
# File 'lib/hashira/report/columns.rb', line 14 def print @io.puts(header) @io.puts(rule) body end |
#rule ⇒ Object
24 |
# File 'lib/hashira/report/columns.rb', line 24 def rule = "-" * [header, *@rows.map { line(it) }].map(&:length).max |