module Sequel::PrettyTable

  1. lib/sequel/extensions/_pretty_table.rb

Methods

Public Class

  1. print
  2. string

Public Class methods

print(records, columns=nil)

Prints nice-looking plain-text tables via puts

+--+-------+
|id|name   |
|--+-------|
|1 |fasdfas|
|2 |test   |
+--+-------+
[show source]
   # File lib/sequel/extensions/_pretty_table.rb
24 def self.print(records, columns=nil)
25   puts string(records, columns)
26 end
string(records, columns = nil)

Return the string that print will print via puts.

[show source]
   # 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