Class: Tabloid::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/tabloid/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Data

Returns a new instance of Data.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tabloid/data.rb', line 6

def initialize(options = {})
  raise ArgumentError.new("Must supply row data") unless options[:rows]
  raise ArgumentError.new("Must supply column data") unless options[:report_columns]

  @report_columns   = options[:report_columns]
  @grouping_key     = options[:grouping_key]
  @grouping_options = options[:grouping_options] || {:total => true}
  @summary_options  = options[:summary] || {}

  @rows = convert_rows(options[:rows])

end

Instance Attribute Details

#report_columnsObject

Returns the value of attribute report_columns.



3
4
5
# File 'lib/tabloid/data.rb', line 3

def report_columns
  @report_columns
end

#rowsObject (readonly)

Returns the value of attribute rows.



4
5
6
# File 'lib/tabloid/data.rb', line 4

def rows
  @rows
end

Instance Method Details

#to_csvObject



19
20
21
# File 'lib/tabloid/data.rb', line 19

def to_csv
  header_csv + rows.map(&:to_csv).join + summary_csv
end

#to_htmlObject



23
24
25
# File 'lib/tabloid/data.rb', line 23

def to_html
  header_html + rows.map(&:to_html).join + summary_html
end