class Thor::Shell::Basic
def print_table(table, options={})
ident
==== Options
Array[Array[String, String, ...]]
==== Parameters
Prints a table.
def print_table(table, options={}) return if table.empty? formats, ident = [], options[:ident].to_i options[:truncate] = terminal_width if options[:truncate] == true 0.upto(table.first.length - 2) do |i| maxima = table.max{ |a,b| a[i].size <=> b[i].size }[i].size formats << "%-#{maxima + 2}s" end formats[0] = formats[0].insert(0, " " * ident) formats << "%s" table.each do |row| sentence = "" row.each_with_index do |column, i| sentence << formats[i] % column.to_s end sentence = truncate(sentence, options[:truncate]) if options[:truncate] $stdout.puts sentence end end