Class: Kiba::Extend::Transforms::Clean::ClearFields
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Clean::ClearFields
- Defined in:
- lib/kiba/extend/transforms/clean.rb
Instance Method Summary collapse
-
#initialize(fields:, if_equals: nil) ⇒ ClearFields
constructor
A new instance of ClearFields.
-
#process(row) ⇒ Object
Constructor Details
#initialize(fields:, if_equals: nil) ⇒ ClearFields
Returns a new instance of ClearFields.
181 182 183 184 |
# File 'lib/kiba/extend/transforms/clean.rb', line 181 def initialize(fields:, if_equals: nil) @fields = [fields].flatten @if_equals = if_equals end |
Instance Method Details
#process(row) ⇒ Object
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/kiba/extend/transforms/clean.rb', line 187 def process(row) @fields.each do |field| if @if_equals.nil? row[field] = nil elsif row[field] == @if_equals row[field] = nil end end row end |