Class: Birt::Core::DataSetResult
- Inherits:
-
Object
- Object
- Birt::Core::DataSetResult
- Defined in:
- lib/birt/core/data_set_result.rb
Instance Attribute Summary collapse
-
#column_headers ⇒ Object
Returns the value of attribute column_headers.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#row_headers ⇒ Object
Returns the value of attribute row_headers.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(data_result) ⇒ DataSetResult
constructor
A new instance of DataSetResult.
Constructor Details
#initialize(data_result) ⇒ DataSetResult
Returns a new instance of DataSetResult.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/birt/core/data_set_result.rb', line 8 def initialize(data_result) @rows, @row_headers, @columns, @column_headers= [], [], [], [] data_result.each do |row| @column_headers = row.keys.inject([]) { |acc, (k,v)| acc<<k.to_s; acc } if column_headers.empty? @row_headers << row.values[0] @rows << row.values row.values.each_with_index { |v, i| @columns[i]||=[]; @columns[i]<<v; } end if data_result end |
Instance Attribute Details
#column_headers ⇒ Object
Returns the value of attribute column_headers.
6 7 8 |
# File 'lib/birt/core/data_set_result.rb', line 6 def column_headers @column_headers end |
#columns ⇒ Object
Returns the value of attribute columns.
5 6 7 |
# File 'lib/birt/core/data_set_result.rb', line 5 def columns @columns end |
#row_headers ⇒ Object
Returns the value of attribute row_headers.
4 5 6 |
# File 'lib/birt/core/data_set_result.rb', line 4 def row_headers @row_headers end |
#rows ⇒ Object
Returns the value of attribute rows.
3 4 5 |
# File 'lib/birt/core/data_set_result.rb', line 3 def rows @rows end |