Class: Kiba::Extend::Transforms::Clean::EmptyFieldGroups

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/transforms/clean.rb

Instance Method Summary collapse

Constructor Details

#initialize(groups:, sep:, use_nullvalue: false) ⇒ EmptyFieldGroups

Returns a new instance of EmptyFieldGroups.

Parameters:

  • groups (Array(Array(Symbol)))

    Each of the arrays inside groups should list all fields that are part of a repeating field group or field subgroup

  • sep (String)

    delimiter used to split/join field values

  • use_nullvalue (String, false) (defaults to: false)

    if a string, will insert that string before any sep at beginning of string, after any sep end of string, and between any two sep with nothing in between. It considers this a blank value, so if all values in a field are %NULLVALUE%, the field will be nil-ed out.



224
225
226
227
228
# File 'lib/kiba/extend/transforms/clean.rb', line 224

def initialize(groups:, sep:, use_nullvalue: false)
  @groups = groups
  @sep = sep
  @use_nullvalue = use_nullvalue
end

Instance Method Details

#process(row) ⇒ Object

Parameters:

  • row (Hash{ Symbol => String, nil })


231
232
233
234
# File 'lib/kiba/extend/transforms/clean.rb', line 231

def process(row)
  @groups.each { |group| process_group(row, group) }
  row
end