Module: Dri::Utils::Table

Instance Method Summary collapse

Instance Method Details



8
9
10
11
12
13
14
15
16
17
# File 'lib/dri/utils/table.rb', line 8

def print_table(headers, rows, alignments: [], **kwargs)
  if alignments.empty?
    (1..headers.size).each do
      alignments.push(:center)
    end
  end

  table = TTY::Table.new(headers, rows)
  puts table.render(:ascii, resize: true, multiline: true, alignments: alignments, **kwargs)
end