Class: Itiel::Extract::CSVFile

Inherits:
Object
  • Object
show all
Includes:
ChainedStep, Nameable
Defined in:
lib/itiel/extract/csv_file.rb

Overview

Extracts all specified CSV file rows and sends it in batches to its next step

Usage:

csv_file            = Itiel::Extract::CSVFile.new('FileName.csv')
csv_file.batch_size = 15
csv.file.start

Instance Attribute Summary collapse

Attributes included from Nameable

#debug, #step_name

Attributes included from ChainedStep

#next_step

Instance Method Summary collapse

Methods included from ChainedStep

#start

Constructor Details

#initialize(file_name) ⇒ CSVFile

Returns a new instance of CSVFile.



21
22
23
# File 'lib/itiel/extract/csv_file.rb', line 21

def initialize(file_name)
  self.file_name = file_name
end

Instance Attribute Details

#file_nameObject

Returns the value of attribute file_name.



19
20
21
# File 'lib/itiel/extract/csv_file.rb', line 19

def file_name
  @file_name
end

Instance Method Details

#extractObject



25
26
27
28
# File 'lib/itiel/extract/csv_file.rb', line 25

def extract
  lines = CSV.read(self.file_name, :headers => true)
  lines.collect(&:to_hash)
end