Sha256: 357c05ddf54c729259d7e30a3eb2ac79b1d4fdb5f4b509a31e09df960bdb0c72

Contents?: true

Size: 880 Bytes

Versions: 1

Compression:

Stored size: 880 Bytes

Contents

require 'hirb'

module PT

  class DataTable

    extend ::Hirb::Console

    def initialize(dataset)
      @rows = dataset.map{ |row| DataRow.new(row, dataset) }
    end

    def print
      if @rows.empty?
        puts "\n         -- empty list --         \n"
      else
        self.class.table @rows, :fields => [:num] + self.class.fields, :unicode => true, :description => false
      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, :current_state, :id]
    end

  end

  class MembersTable < DataTable

    def self.fields
      [:name]
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pt-0.5.5 lib/pt/data_table.rb