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
29 def self.string(records, columns = nil) # records is an array of hashes
30   columns ||= records.first.keys.sort
31   sizes = column_sizes(records, columns)
32   sep_line = separator_line(columns, sizes)
33 
34   array = [sep_line, header_line(columns, sizes), sep_line]
35   records.each {|r| array << data_line(columns, sizes, r)}
36   array << sep_line
37   array.join("\n")
38 end