Class: Kiba::Plus::Destination::Csv

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/plus/destination/csv.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Csv

Returns a new instance of Csv.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kiba/plus/destination/csv.rb', line 7

def initialize(options = {})
  @options = options
  @options.assert_valid_keys(
    :output_file,
    :mode,
    :row_sep,
    :col_sep,
    :force_quotes,
    :quote_char
  )
  @csv = CSV.open(output_file, mode, {
    :col_sep => col_sep,
    :quote_char => quote_char,
    :force_quotes => force_quotes,
    :row_sep => row_sep
  })
end

Instance Attribute Details

#csvObject (readonly)

Returns the value of attribute csv.



5
6
7
# File 'lib/kiba/plus/destination/csv.rb', line 5

def csv
  @csv
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/kiba/plus/destination/csv.rb', line 5

def options
  @options
end

Instance Method Details

#closeObject



29
30
31
# File 'lib/kiba/plus/destination/csv.rb', line 29

def close
  @csv.close
end

#write(row) ⇒ Object



25
26
27
# File 'lib/kiba/plus/destination/csv.rb', line 25

def write(row)
  @csv << row.values
end