Class: CSVPlusPlus::Row
- Inherits:
-
Object
- Object
- CSVPlusPlus::Row
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/row.rb
Overview
A row of a template. A row contains an Array
of Cells and possibly a row-level Modifier
.
Instance Attribute Summary collapse
-
#cells ⇒ Array<Cell>
readonly
The cells contained by this row.
-
#index ⇒ Integer
The index of this row.
-
#modifier ⇒ Modifier
readonly
The modifier to apply to all cells in this row.
Instance Method Summary collapse
-
#expand_amount ⇒ Integer
How much this row will expand itself, if at all (0).
-
#expand_rows(starts_at:, into: []) ⇒ Array<Row>
Starting at
starts_at
, do a deep copy of this row into theArray
referenced byinto
. -
#initialize(cells:, index:, modifier:) ⇒ Row
constructor
A new instance of Row.
-
#unexpanded? ⇒ T::Boolean
Does the row have an ![[expand]] modifier but is yet to be expanded?.
Constructor Details
#initialize(cells:, index:, modifier:) ⇒ Row
Returns a new instance of Row.
28 29 30 31 32 |
# File 'lib/csv_plus_plus/row.rb', line 28 def initialize(cells:, index:, modifier:) @cells = cells @modifier = modifier @index = index end |
Instance Attribute Details
#cells ⇒ Array<Cell> (readonly)
The cells contained by this row.
10 11 12 |
# File 'lib/csv_plus_plus/row.rb', line 10 def cells @cells end |
#index ⇒ Integer
The index of this row. Starts at 0.
10 11 12 |
# File 'lib/csv_plus_plus/row.rb', line 10 def index @index end |
#modifier ⇒ Modifier (readonly)
The modifier to apply to all cells in this row
10 11 12 |
# File 'lib/csv_plus_plus/row.rb', line 10 def modifier @modifier end |
Instance Method Details
#expand_amount ⇒ Integer
How much this row will expand itself, if at all (0)
47 48 49 50 51 |
# File 'lib/csv_plus_plus/row.rb', line 47 def return 0 if @modifier..nil? ::T.must(@modifier.).repetitions || (1000 - @index) end |
#expand_rows(starts_at:, into: []) ⇒ Array<Row>
Starting at starts_at
, do a deep copy of this row into the Array
referenced by into
.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/csv_plus_plus/row.rb', line 60 def (starts_at:, into: []) return into if @modifier..nil? ::T.must(@modifier.).starts_at = starts_at starts_at.upto( + starts_at - 1) do |row_index| into << deep_clone.tap { |c| c.index = row_index } end into end |
#unexpanded? ⇒ T::Boolean
Does the row have an ![[expand]] modifier but is yet to be expanded?
75 76 77 78 79 |
# File 'lib/csv_plus_plus/row.rb', line 75 def return false if @modifier..nil? !::T.must(@modifier.). end |