Module: CSVPlusPlus::Writer

Defined in:
lib/csv_plus_plus/writer.rb,
lib/csv_plus_plus/writer/csv.rb,
lib/csv_plus_plus/writer/excel.rb,
lib/csv_plus_plus/writer/base_writer.rb,
lib/csv_plus_plus/writer/google_sheets.rb,
lib/csv_plus_plus/writer/open_document.rb,
lib/csv_plus_plus/writer/google_sheet_builder.rb

Overview

Various strategies for writing to various formats (excel, google sheets, CSV, OpenDocument)

Defined Under Namespace

Classes: BaseWriter, CSV, Excel, GoogleSheetBuilder, GoogleSheets, OpenDocument

Class Method Summary collapse

Class Method Details

.writer(options) ⇒ Object

Return an instance of a writer depending on the given options



14
15
16
17
18
19
20
21
22
23
# File 'lib/csv_plus_plus/writer.rb', line 14

def self.writer(options)
  return ::CSVPlusPlus::Writer::GoogleSheets.new(options) if options.google

  case options.output_filename
  when /\.csv$/ then ::CSVPlusPlus::Writer::CSV.new(options)
  when /\.ods$/ then ::CSVPlusPlus::Writer::OpenDocument.new(options)
  when /\.xls$/ then ::CSVPlusPlus::Writer::Excel.new(options)
  else raise(::StandardError, "Unsupported extension: #{options.output_filename}")
  end
end