Method: ObjectTable::Printing.format_rows

Defined in:
lib/object_table/printing.rb

.format_rows(rows, widths) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/object_table/printing.rb', line 45

def self.format_rows(rows, widths)
  rows = rows.flat_map do |row|
    height = row.map(&:length).max
    row.map{|cell| cell.fill('', cell.length...height)}.transpose
  end

  format = widths.to_a.map{|w| "%#{w}s"}.join
  rows.map{|row| format % row }
end