Class: Kiba::Uncommon::Destinations::CSV
- Inherits:
-
Object
- Object
- Kiba::Uncommon::Destinations::CSV
- Defined in:
- lib/kiba/uncommon/destinations/csv.rb
Instance Attribute Summary collapse
-
#output_file ⇒ Object
readonly
Returns the value of attribute output_file.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(output_file) ⇒ CSV
constructor
A new instance of CSV.
- #write(row) ⇒ Object
Constructor Details
#initialize(output_file) ⇒ CSV
Returns a new instance of CSV.
8 9 10 11 |
# File 'lib/kiba/uncommon/destinations/csv.rb', line 8 def initialize(output_file) @output_file = output_file @csv = ::CSV.open(output_file, 'w') end |
Instance Attribute Details
#output_file ⇒ Object (readonly)
Returns the value of attribute output_file.
6 7 8 |
# File 'lib/kiba/uncommon/destinations/csv.rb', line 6 def output_file @output_file end |
Instance Method Details
#close ⇒ Object
21 22 23 |
# File 'lib/kiba/uncommon/destinations/csv.rb', line 21 def close @csv.close end |
#write(row) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/kiba/uncommon/destinations/csv.rb', line 13 def write(row) unless @headers_written @headers_written = true @csv << row.keys end @csv << row.values end |