Class: Hyrax::Ingest::Fetcher::CSVFile

Inherits:
Base
  • Object
show all
Includes:
HasIteration, HasSIP
Defined in:
lib/hyrax/ingest/fetcher/csv_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasIteration

#iteration, #iteration=

Methods included from HasSIP

#sip, #sip=

Methods inherited from Base

#required?

Methods included from HasLogger

config, #logger, #logger=

Methods included from HasReport

#report, #report=

Constructor Details

#initialize(options = {}) ⇒ CSVFile

Returns a new instance of CSVFile.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hyrax/ingest/fetcher/csv_file.rb', line 15

def initialize(options={})
  raise ArgumentError, "Required option :filename is missing" unless options.key?(:filename)
  raise ArgumentError, "Required option :column is missing" unless options.key?(:column)
  raise ArgumentError, "Required option :row is missing" unless options.key?(:row)

  @filename = options.fetch(:filename)
  @column = options.fetch(:column, '').to_s.strip.downcase
  @row = options.fetch(:row, '').to_s.strip.downcase
  @header_row_number = options.fetch(:header_row_number, 1)
  @row_offset = options[:row_offset]
  super
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



10
11
12
# File 'lib/hyrax/ingest/fetcher/csv_file.rb', line 10

def column
  @column
end

#filenameObject (readonly)

Returns the value of attribute filename.



10
11
12
# File 'lib/hyrax/ingest/fetcher/csv_file.rb', line 10

def filename
  @filename
end

#header_row_numberObject (readonly)

Returns the value of attribute header_row_number.



10
11
12
# File 'lib/hyrax/ingest/fetcher/csv_file.rb', line 10

def header_row_number
  @header_row_number
end

#rowObject (readonly)

Returns the value of attribute row.



10
11
12
# File 'lib/hyrax/ingest/fetcher/csv_file.rb', line 10

def row
  @row
end

Instance Method Details

#fetchObject



28
29
30
# File 'lib/hyrax/ingest/fetcher/csv_file.rb', line 28

def fetch
  @fetched_value ||= cell_value
end