Class: ArrayTransform::Operations::AddIndexColumn
- Inherits:
-
Object
- Object
- ArrayTransform::Operations::AddIndexColumn
- Includes:
- Callable
- Defined in:
- lib/array_transform/operations/add_index_column.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(new_column_header: nil, data:, index_offset: 0) ⇒ AddIndexColumn
constructor
TODO: take a custom number generator? TODO: support before/after (before_column_header, after_column_header) [1, 2, 3].insert(1, 4) => [1, 4, 2, 3].
Methods included from Callable
Constructor Details
#initialize(new_column_header: nil, data:, index_offset: 0) ⇒ AddIndexColumn
TODO: take a custom number generator? TODO: support before/after (before_column_header, after_column_header) [1, 2, 3].insert(1, 4)
=> [1, 4, 2, 3]
11 12 13 14 15 16 17 18 19 |
# File 'lib/array_transform/operations/add_index_column.rb', line 11 def initialize( new_column_header: nil, data:, index_offset: 0 ) @new_column_header = new_column_header @data = data @index_offset = index_offset end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
21 22 23 |
# File 'lib/array_transform/operations/add_index_column.rb', line 21 def data @data end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/array_transform/operations/add_index_column.rb', line 23 def call AddColumn.call( cell_operation: -> (row_index) { row_index + index_offset }, data: data, new_column_header: new_column_header ) end |