class Goldmine::RollupResult

Attributes

pivot_result[R]

Public Class Methods

new(pivot_result={}) click to toggle source
# File lib/goldmine/rollup_result.rb, line 11
def initialize(pivot_result={})
  @pivot_result = pivot_result
end

Public Instance Methods

to_csv_table() click to toggle source
# File lib/goldmine/rollup_result.rb, line 35
def to_csv_table
  rows = to_tabular
  header = rows.shift
  csv_rows = rows.map { |row| CSV::Row.new(header, row) }
  CSV::Table.new csv_rows
end
to_hash_rows() click to toggle source
# File lib/goldmine/rollup_result.rb, line 21
def to_hash_rows
  pivot_result.each_with_object([]) do |pair, memo|
    memo << (pair.first + pair.last).to_h
  end
end
to_rows() click to toggle source
# File lib/goldmine/rollup_result.rb, line 15
def to_rows
  pivot_result.each_with_object([]) do |pair, memo|
    memo << pair.first + pair.last
  end
end
to_tabular() click to toggle source
# File lib/goldmine/rollup_result.rb, line 27
def to_tabular
  rows = to_rows
  values = rows.map { |r| r.map(&:last) }
  sample = rows.first || []
  values.unshift sample.map(&:first)
  values
end