class Terminal::Table

Public Class Methods

from_hashes(array) click to toggle source
# File lib/terminal-tableofhashes.rb, line 6
def self.from_hashes(array)

  headings = Set.new
  array.each do |hash|
    hash.each do |k, v|
      headings << k
    end
  end

  rows = []
  array.each do |hash|
    row = []
    headings.each do |name|
      row << hash[name]
    end
    rows << row
  end

  new headings: headings, rows: rows
end