Class: Kiba::Extend::Transforms::Delete::Fields
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Delete::Fields
- Defined in:
- lib/kiba/extend/transforms/delete/fields.rb
Overview
Deletes field(s) passed in fields
parameter.
Examples
Input table:
| a | b | c |
|---+---+---|
| 1 | 2 | 3 |
Used in pipeline as:
transform Delete::Fields, fields: %i[a c]
Results in:
| b |
|---|
| 2 |
Used in pipeline as:
transform Delete::Fields, fields: :b
Results in:
| a | c |
|---+---|
| 1 | 3 |
Instance Method Summary collapse
-
#initialize(fields:) ⇒ Fields
constructor
A new instance of Fields.
-
#process(row) ⇒ Object
Constructor Details
#initialize(fields:) ⇒ Fields
Returns a new instance of Fields.
49 50 51 |
# File 'lib/kiba/extend/transforms/delete/fields.rb', line 49 def initialize(fields:) @fields = [fields].flatten end |
Instance Method Details
#process(row) ⇒ Object
54 55 56 57 |
# File 'lib/kiba/extend/transforms/delete/fields.rb', line 54 def process(row) fields.each { |name| row.delete(name) } row end |