Class: Kiba::Extend::Transforms::Cspace::ConvertToID

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

Instance Method Summary collapse

Constructor Details

#initialize(source:, target:) ⇒ ConvertToID

Returns a new instance of ConvertToID.



8
9
10
11
# File 'lib/kiba/extend/transforms/cspace/convert_to_id.rb', line 8

def initialize(source:, target:)
  @source = source
  @target = target
end

Instance Method Details

#process(row) ⇒ Object

Parameters:

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


14
15
16
17
18
19
# File 'lib/kiba/extend/transforms/cspace/convert_to_id.rb', line 14

def process(row)
  val = row.fetch(@source, "")
  idval = val.gsub(/\W/, "")
  row[@target] = "#{idval}#{XXhash.xxh32(idval)}"
  row
end