Class: MagicReport::Report::Row
- Inherits:
-
Object
- Object
- MagicReport::Report::Row
- Defined in:
- lib/magic_report/report/row.rb
Defined Under Namespace
Classes: Column
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#nested_rows ⇒ Object
readonly
Returns the value of attribute nested_rows.
Instance Method Summary collapse
- #add_column_value(key:, value:) ⇒ Object
- #add_nested_row(key:, row:) ⇒ Object
- #headings ⇒ Object
-
#initialize ⇒ Row
constructor
A new instance of Row.
- #register_column(key, heading, is_primary, prefix = nil) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ Row
Returns a new instance of Row.
28 29 30 31 |
# File 'lib/magic_report/report/row.rb', line 28 def initialize @columns = [] @nested_rows = {} end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
26 27 28 |
# File 'lib/magic_report/report/row.rb', line 26 def columns @columns end |
#nested_rows ⇒ Object (readonly)
Returns the value of attribute nested_rows.
26 27 28 |
# File 'lib/magic_report/report/row.rb', line 26 def nested_rows @nested_rows end |
Instance Method Details
#add_column_value(key:, value:) ⇒ Object
33 34 35 |
# File 'lib/magic_report/report/row.rb', line 33 def add_column_value(key:, value:) @columns.find { |column| column.key == key }.assign_value(value) end |
#add_nested_row(key:, row:) ⇒ Object
37 38 39 |
# File 'lib/magic_report/report/row.rb', line 37 def add_nested_row(key:, row:) nested_rows[key] = row end |
#headings ⇒ Object
45 46 47 |
# File 'lib/magic_report/report/row.rb', line 45 def headings (columns.map(&:full_heading) + nested_rows.values.map(&:headings)).flatten end |
#register_column(key, heading, is_primary, prefix = nil) ⇒ Object
41 42 43 |
# File 'lib/magic_report/report/row.rb', line 41 def register_column(key, heading, is_primary, prefix = nil) @columns << Column.new(key, heading, is_primary, prefix) end |
#to_a ⇒ Object
49 50 51 |
# File 'lib/magic_report/report/row.rb', line 49 def to_a (columns.map(&:value) + nested_rows.values.map(&:to_a)).flatten end |