Class: CSVPlusPlus::Modifier::Expand
- Inherits:
-
Object
- Object
- CSVPlusPlus::Modifier::Expand
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/modifier/expand.rb
Overview
The logic for how a row can expand
Instance Attribute Summary collapse
-
#ends_at ⇒ Integer?
readonly
Once the row has been expanded, where it ends at.
-
#repetitions ⇒ Integer?
readonly
How many times the row repeats/expands.
-
#starts_at ⇒ Integer?
Once the row has been expanded, where it starts at.
Instance Method Summary collapse
-
#expanded? ⇒ boolean
Has the row been expanded?.
-
#infinite? ⇒ boolean
Does this infinitely expand?.
-
#initialize(repetitions: nil, starts_at: nil) ⇒ Expand
constructor
A new instance of Expand.
-
#position_within?(position) ⇒ boolean
Does the given
position
fall within this expand?.
Constructor Details
#initialize(repetitions: nil, starts_at: nil) ⇒ Expand
Returns a new instance of Expand.
29 30 31 32 33 |
# File 'lib/csv_plus_plus/modifier/expand.rb', line 29 def initialize(repetitions: nil, starts_at: nil) @repetitions = ::T.let(repetitions, ::T.nilable(::Integer)) @starts_at = ::T.let(starts_at, ::T.nilable(::Integer)) unless starts_at.nil? @ends_at = ::T.let(nil, ::T.nilable(::Integer)) end |
Instance Attribute Details
#ends_at ⇒ Integer? (readonly)
Once the row has been expanded, where it ends at.
11 12 13 |
# File 'lib/csv_plus_plus/modifier/expand.rb', line 11 def ends_at @ends_at end |
#repetitions ⇒ Integer? (readonly)
How many times the row repeats/expands.
11 12 13 |
# File 'lib/csv_plus_plus/modifier/expand.rb', line 11 def repetitions @repetitions end |
#starts_at ⇒ Integer?
Once the row has been expanded, where it starts at.
11 12 13 |
# File 'lib/csv_plus_plus/modifier/expand.rb', line 11 def starts_at @starts_at end |
Instance Method Details
#expanded? ⇒ boolean
Has the row been expanded?
39 40 41 |
# File 'lib/csv_plus_plus/modifier/expand.rb', line 39 def !@starts_at.nil? end |
#infinite? ⇒ boolean
Does this infinitely expand?
47 48 49 |
# File 'lib/csv_plus_plus/modifier/expand.rb', line 47 def infinite? repetitions.nil? end |
#position_within?(position) ⇒ boolean
Does the given position
fall within this expand?
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/csv_plus_plus/modifier/expand.rb', line 66 def position_within?(position) unless starts_at raise( ::CSVPlusPlus::Error::CompilerError, 'Must call Template.expand_rows! before checking the scope of expands.' ) end position.row_index >= ::T.must(starts_at) && (ends_at.nil? || position.row_index <= ::T.must(ends_at)) end |