Class: ASpaceImport::CSVConvert::CellHandler

Inherits:
Object
  • Object
show all
Defined in:
backend/app/converters/lib/csv_converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, data_path, val_filter = nil) ⇒ CellHandler

Returns a new instance of CellHandler.



150
151
152
153
154
# File 'backend/app/converters/lib/csv_converter.rb', line 150

def initialize(name, data_path, val_filter = nil)
  @name = name
  @target_key, @target_path = data_path.split(".")
  @val_filter = val_filter
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name



146
147
148
# File 'backend/app/converters/lib/csv_converter.rb', line 146

def name
  @name
end

#target_keyObject (readonly)

Returns the value of attribute target_key



147
148
149
# File 'backend/app/converters/lib/csv_converter.rb', line 147

def target_key
  @target_key
end

#target_pathObject (readonly)

Returns the value of attribute target_path



148
149
150
# File 'backend/app/converters/lib/csv_converter.rb', line 148

def target_path
  @target_path
end

Instance Method Details

#extract_value(cell_contents) ⇒ Object



157
158
159
160
# File 'backend/app/converters/lib/csv_converter.rb', line 157

def extract_value(cell_contents)
  return nil if cell_contents.nil? || cell_contents == 'NULL'
  @val_filter ? @val_filter.call(cell_contents) : cell_contents
end