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/rubyxl_builder.rb,
lib/csv_plus_plus/writer/rubyxl_modifier.rb,
lib/csv_plus_plus/writer/file_backer_upper.rb,
lib/csv_plus_plus/writer/google_sheet_builder.rb,
lib/csv_plus_plus/writer/google_sheet_modifier.rb

Overview

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

Defined Under Namespace

Modules: FileBackerUpper Classes: BaseWriter, CSV, Excel, GoogleSheetBuilder, GoogleSheetModifier, GoogleSheets, OpenDocument, RubyXLBuilder, RubyXLModifier

Class Method Summary collapse

Class Method Details

.writer(options) ⇒ Object

Return an instance of a writer depending on the given options



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

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 /\.xl(sx|sm|tx|tm)$/ then ::CSVPlusPlus::Writer::Excel.new(options)
  else raise(::CSVPlusPlus::Error, "Unsupported file extension: #{options.output_filename}")
  end
end