Sha256: 452f1fdd1de09390f47c2b33f7fbc8f2b01a6295b4e9feed23f8992a6a164c22
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
require 'hirb' module PT class DataTable extend ::Hirb::Console def initialize(dataset) @rows = dataset.map{ |row| DataRow.new(row, dataset) } end 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 def [](pos) pos = pos.to_i (pos < 1 || pos > @rows.length) ? nil : @rows[pos-1].record end def length @rows.length end def self.fields [] end end class ProjectTable < DataTable def self.fields [:name] end end class TasksTable < DataTable def self.fields [:name, :state, :id] end end class MultiUserTasksTable < DataTable def self.fields [:owned_by, :name, :state, :id] end end class MembersTable < DataTable def self.fields [:name] end end class TodoTaskTable < DataTable def self.fields [:description] end end class ActionTable < DataTable def self.fields [:action] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pt-0.7.3 | lib/pt/data_table.rb |
pt-0.7.2 | lib/pt/data_table.rb |