Class: Kiba::Extend::Transforms::Delete::FieldValueMatchingRegexp
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Delete::FieldValueMatchingRegexp
- Defined in:
- lib/kiba/extend/transforms/delete/field_value_matching_regexp.rb
Overview
Deletes full field value of all given fields that match the given regular expression pattern. You can control whether the regexp is case sensitive or not.
Instance Method Summary collapse
-
#initialize(fields:, match:, casesensitive: true) ⇒ FieldValueMatchingRegexp
constructor
A new instance of FieldValueMatchingRegexp.
-
#process(row) ⇒ Object
Constructor Details
#initialize(fields:, match:, casesensitive: true) ⇒ FieldValueMatchingRegexp
Returns a new instance of FieldValueMatchingRegexp.
106 107 108 109 110 |
# File 'lib/kiba/extend/transforms/delete/field_value_matching_regexp.rb', line 106 def initialize(fields:, match:, casesensitive: true) @fields = [fields].flatten @casesensitive = casesensitive @match = set_match(match) end |
Instance Method Details
#process(row) ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/kiba/extend/transforms/delete/field_value_matching_regexp.rb', line 113 def process(row) fields.each do |field| val = row.fetch(field, nil) next if val.blank? row[field] = nil if val.match?(match) end row end |