Class: Kamome::CsvHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/kamome/csv_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(operation) ⇒ CsvHandler

Returns a new instance of CsvHandler.



9
10
11
# File 'lib/kamome/csv_handler.rb', line 9

def initialize(operation)
  @operation = operation
end

Instance Method Details

#call(csv_path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/kamome/csv_handler.rb', line 13

def call(csv_path)
  prev = nil
  ::CSV.foreach(csv_path) do |row|
    obj = transform(row)
    next if skip?(prev, obj)

    yield(obj, $INPUT_LINE_NUMBER)
    prev = obj
  end
end