class PTT::DataTable
Public Class Methods
fields()
click to toggle source
# File lib/ptt/data_table.rb, line 40 def self.fields [] end
new(dataset)
click to toggle source
# File lib/ptt/data_table.rb, line 10 def initialize(dataset) @rows = dataset.map{ |row| DataRow.new(row, dataset) } end
Public Instance Methods
[](pos)
click to toggle source
# File lib/ptt/data_table.rb, line 31 def [](pos) pos = pos.to_i (pos < 1 || pos > @rows.length) ? nil : @rows[pos-1].record end
length()
click to toggle source
# File lib/ptt/data_table.rb, line 36 def length @rows.length end
print(config={})
click to toggle source
# File lib/ptt/data_table.rb, line 14 def print(config={}) if @rows.empty? puts "\n#{'-- empty list --'.center(36)}\n" else max_width = Hirb::Util.detect_terminal_size()[0] if config[:max_width] && config[:max_width] < max_width max_width = config[:max_width] end self.class.table @rows, :fields => [:num] + self.class.fields, :change_fields => %w{num pt_id}, :unicode => true, :description => false, :max_width => max_width end end