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

- (CellHandler) initialize(name, data_path, val_filter = nil)

Returns a new instance of CellHandler



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

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

- (Object) name (readonly)

Returns the value of attribute name



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

def name
  @name
end

- (Object) target_key (readonly)

Returns the value of attribute target_key



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

def target_key
  @target_key
end

- (Object) target_path (readonly)

Returns the value of attribute target_path



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

def target_path
  @target_path
end

Instance Method Details

- (Object) extract_value(cell_contents)



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

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