Class: Kiba::Extend::Transforms::Delete::FieldnamesStartingWith
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Delete::FieldnamesStartingWith
- Defined in:
- lib/kiba/extend/transforms/delete/fieldnames_starting_with.rb
Overview
Deletes field(s) whose names begin with the given prefix string
Instance Method Summary collapse
-
#initialize(prefix:) ⇒ FieldnamesStartingWith
constructor
A new instance of FieldnamesStartingWith.
-
#process(row) ⇒ Object
Constructor Details
#initialize(prefix:) ⇒ FieldnamesStartingWith
Returns a new instance of FieldnamesStartingWith.
35 36 37 |
# File 'lib/kiba/extend/transforms/delete/fieldnames_starting_with.rb', line 35 def initialize(prefix:) @prefix = prefix end |
Instance Method Details
#process(row) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/kiba/extend/transforms/delete/fieldnames_starting_with.rb', line 40 def process(row) row.keys.each do |field| next unless field.to_s.start_with?(prefix) row.delete(field) end row end |