Class: CsvInZip::CsvFile

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ CsvFile

Returns a new instance of CsvFile.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/csv_in_zip.rb', line 12

def initialize(options = {}, &block)
  if options[:change_headers].present?
    options[:headers] = options[:change_headers]
    options[:remove_header_line] = true
  end
  @options = options
  
  @tempfile = Tempfile.open("csv_in_zip")
  if options[:headers].present?
    @tempfile.puts Array(options[:headers]).join(",")
  end
  
  instance_eval(&block)
ensure
  @tempfile.close
end