Class: Abbu::Exporters::CsvExporter
- Inherits:
-
Object
- Object
- Abbu::Exporters::CsvExporter
- Defined in:
- lib/abbu/exporters/csv_exporter.rb
Instance Method Summary collapse
-
#initialize(contacts) ⇒ CsvExporter
constructor
A new instance of CsvExporter.
- #to_file(path) ⇒ Object
- #to_stdout ⇒ Object
Constructor Details
#initialize(contacts) ⇒ CsvExporter
Returns a new instance of CsvExporter.
9 10 11 |
# File 'lib/abbu/exporters/csv_exporter.rb', line 9 def initialize(contacts) @contacts = contacts end |
Instance Method Details
#to_file(path) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/abbu/exporters/csv_exporter.rb', line 13 def to_file(path) CSV.open(path, 'w') do |csv| csv << headers @contacts.each { |c| csv << row(c) } end end |
#to_stdout ⇒ Object
20 21 22 23 24 25 |
# File 'lib/abbu/exporters/csv_exporter.rb', line 20 def to_stdout puts(CSV.generate do |csv| csv << headers @contacts.each { |c| csv << row(c) } end) end |