module Sequel::PrettyTable

Public Class Methods

print(records, columns=nil) click to toggle source

Prints nice-looking plain-text tables via puts

+--+-------+
|id|name   |
|--+-------|
|1 |fasdfas|
|2 |test   |
+--+-------+
string(records, columns = nil) click to toggle source

Return the string that print will print via puts.

# File lib/sequel/extensions/_pretty_table.rb, line 25
def self.string(records, columns = nil) # records is an array of hashes
  columns ||= records.first.keys.sort_by{|x|x.to_s}
  sizes = column_sizes(records, columns)
  sep_line = separator_line(columns, sizes)

  array = [sep_line, header_line(columns, sizes), sep_line]
  records.each {|r| array << data_line(columns, sizes, r)}
  array << sep_line
  array.join("\n")
end