class PutsUtils::PutsTable::Table
Public Class Methods
new(headers, data)
click to toggle source
# File lib/puts_utils/puts_table/table.rb, line 6 def initialize(headers, data) @headers = headers || [] @data = data || [] @columns = {} end
Public Instance Methods
column(index)
click to toggle source
# File lib/puts_utils/puts_table/table.rb, line 16 def column(index) key = index.to_s.to_sym return @columns[key] if @columns.key?(key) @columns[key] = rows.map { |r| r[index] } end
rows()
click to toggle source
# File lib/puts_utils/puts_table/table.rb, line 12 def rows @rows ||= [@headers] + @data end