Class: Nanoc::Telemetry::Table
- Inherits:
-
Object
- Object
- Nanoc::Telemetry::Table
- Defined in:
- lib/nanoc/telemetry/table.rb
Instance Method Summary collapse
-
#initialize(rows) ⇒ Table
constructor
A new instance of Table.
-
#to_s ⇒ Object
Constructor Details
#initialize(rows) ⇒ Table
Returns a new instance of Table
5 6 7 |
# File 'lib/nanoc/telemetry/table.rb', line 5 def initialize(rows) @rows = rows end |
Instance Method Details
#to_s ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/nanoc/telemetry/table.rb', line 9 def to_s columns = @rows.transpose column_lengths = columns.map { |c| c.map(&:size).max } [].tap do |lines| lines << row_to_s(@rows[0], column_lengths) lines << separator(column_lengths) lines.concat(@rows.drop(1).map { |r| row_to_s(r, column_lengths) }) end.join("\n") end |