Class: Timely::Formats::Hash

Inherits:
Timely::Formatter show all
Defined in:
lib/timely/formats/hash.rb

Instance Attribute Summary

Attributes inherited from Timely::Formatter

#options, #report

Instance Method Summary collapse

Methods inherited from Timely::Formatter

#initialize, #to_s

Constructor Details

This class inherits a constructor from Timely::Formatter

Instance Method Details

#outputObject

Turn a report into a simple hash keyed off of the row titles



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/timely/formats/hash.rb', line 5

def output
  {}.tap do |hash|
    raw = report.raw

    # headings
    hash[""] = report.columns.map(&:title)

    # data
    raw.each do |row, cells|
      hash[row.title] = cells.map(&:value)
    end
  end
end