Class: Tabloid::Data
- Inherits:
-
Object
- Object
- Tabloid::Data
- Defined in:
- lib/tabloid/data.rb
Instance Attribute Summary collapse
-
#report_columns ⇒ Object
Returns the value of attribute report_columns.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Data
constructor
A new instance of Data.
- #to_csv ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Data
Returns a new instance of Data.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/tabloid/data.rb', line 6 def initialize( = {}) raise ArgumentError.new("Must supply row data") unless [:rows] raise ArgumentError.new("Must supply column data") unless [:report_columns] @report_columns = [:report_columns] @grouping_key = [:grouping_key] @grouping_options = [:grouping_options] || {:total => true} @summary_options = [:summary] || {} @rows = convert_rows([:rows]) end |
Instance Attribute Details
#report_columns ⇒ Object
Returns the value of attribute report_columns.
3 4 5 |
# File 'lib/tabloid/data.rb', line 3 def report_columns @report_columns end |
#rows ⇒ Object (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_csv ⇒ Object
19 20 21 |
# File 'lib/tabloid/data.rb', line 19 def to_csv header_csv + rows.map(&:to_csv).join + summary_csv end |
#to_html ⇒ Object
23 24 25 |
# File 'lib/tabloid/data.rb', line 23 def to_html header_html + rows.map(&:to_html).join + summary_html end |