Class: CSVPlusPlus::Template
- Inherits:
-
Object
- Object
- CSVPlusPlus::Template
- Defined in:
- lib/csv_plus_plus/template.rb
Overview
Contains the flow and data from a code section and CSV section
Instance Attribute Summary collapse
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#expand_rows! ⇒ Object
Apply any expand= modifiers to the parsed template.
-
#initialize(rows:, scope:) ⇒ Template
constructor
initialize.
-
#to_s ⇒ Object
to_s.
-
#validate_infinite_expands(runtime) ⇒ Object
Make sure that the template has a valid amount of infinite expand modifiers.
Constructor Details
#initialize(rows:, scope:) ⇒ Template
initialize
9 10 11 12 |
# File 'lib/csv_plus_plus/template.rb', line 9 def initialize(rows:, scope:) @rows = rows @scope = scope end |
Instance Attribute Details
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
6 7 8 |
# File 'lib/csv_plus_plus/template.rb', line 6 def rows @rows end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'lib/csv_plus_plus/template.rb', line 6 def scope @scope end |
Instance Method Details
#expand_rows! ⇒ Object
Apply any expand= modifiers to the parsed template
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/csv_plus_plus/template.rb', line 20 def = [] row_index = 0 ( lambda do |new_row| new_row.index = row_index << new_row row_index += 1 end ) @rows = end |
#to_s ⇒ Object
to_s
15 16 17 |
# File 'lib/csv_plus_plus/template.rb', line 15 def to_s "Template(rows: #{@rows}, scope: #{@scope})" end |
#validate_infinite_expands(runtime) ⇒ Object
Make sure that the template has a valid amount of infinite expand modifiers
35 36 37 38 39 40 41 42 43 |
# File 'lib/csv_plus_plus/template.rb', line 35 def (runtime) = @rows.filter { |r| r.modifier.&.infinite? } return unless .length > 1 runtime.raise_syntax_error( 'You can only have one infinite expand= (on all others you must specify an amount)', [1] ) end |