Class: GnCrossmap::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/gn_crossmap/reader.rb

Overview

Reads supplied csv file and creates ruby structure to compare with a Global Names Resolver source

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(csv_io, input_name, skip_original, alt_headers, stats) ⇒ Reader

Returns a new instance of Reader.



9
10
11
12
13
14
15
16
17
18
# File 'lib/gn_crossmap/reader.rb', line 9

def initialize(csv_io, input_name, skip_original, alt_headers, stats)
  @stats = stats
  @alt_headers = alt_headers
  @csv_io = csv_io
  @col_sep = detect_col_sep
  @quote_char = quote_char(@col_sep)
  @original_fields = nil
  @input_name = input_name
  @skip_original = skip_original
end

Instance Attribute Details

#col_sepObject (readonly)

Returns the value of attribute col_sep.



7
8
9
# File 'lib/gn_crossmap/reader.rb', line 7

def col_sep
  @col_sep
end

#original_fieldsObject (readonly)

Returns the value of attribute original_fields.



7
8
9
# File 'lib/gn_crossmap/reader.rb', line 7

def original_fields
  @original_fields
end

Instance Method Details

#readObject



20
21
22
23
24
25
# File 'lib/gn_crossmap/reader.rb', line 20

def read
  @stats.stats[:ingestion_start] = Time.now
  @stats.stats[:status] = :ingestion
  GnCrossmap.log("Read input from #{@input_name}")
  block_given? ? parse_input(&Proc.new) : parse_input
end