Module: CSVPlusPlus::Writer

Extended by:
T::Sig
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/merger.rb,
lib/csv_plus_plus/writer/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/file_backer_upper.rb,
lib/csv_plus_plus/writer/google_sheets_builder.rb

Overview

Various strategies for writing to various formats (excel, google sheets, CSV & OpenDocument (not yet implemented))

Defined Under Namespace

Modules: FileBackerUpper, Merger Classes: CSV, Excel, GoogleSheets, GoogleSheetsBuilder, OpenDocument, RubyXLBuilder, Writer

Class Method Summary collapse

Class Method Details

.csv(options, position) ⇒ Object

Instantiate a CSV writer



56
57
58
# File 'lib/csv_plus_plus/writer.rb', line 56

def self.csv(options, position)
  ::CSVPlusPlus::Writer::CSV.new(::T.cast(options, ::CSVPlusPlus::Options::FileOptions), position)
end

.excel(options, position) ⇒ Object

Instantiate a Excel writer



67
68
69
# File 'lib/csv_plus_plus/writer.rb', line 67

def self.excel(options, position)
  ::CSVPlusPlus::Writer::Excel.new(::T.cast(options, ::CSVPlusPlus::Options::FileOptions), position)
end

.google_sheets(options, position) ⇒ Object

Instantiate a GoogleSheets writer



78
79
80
# File 'lib/csv_plus_plus/writer.rb', line 78

def self.google_sheets(options, position)
  ::CSVPlusPlus::Writer::GoogleSheets.new(::T.cast(options, ::CSVPlusPlus::Options::GoogleSheetsOptions), position)
end

.open_document(options, position) ⇒ Object

Instantiate an OpenDocument writer



89
90
91
# File 'lib/csv_plus_plus/writer.rb', line 89

def self.open_document(options, position)
  ::CSVPlusPlus::Writer::OpenDocument.new(::T.cast(options, ::CSVPlusPlus::Options::FileOptions), position)
end

.writer(options, position) ⇒ Writer::CSV | Writer::Excel | Writer::GoogleSheets | Writer::OpenDocument

Return an instance of a writer depending on the given options

Parameters:

  • options (Options)

    The supplied options.

  • position (Position)

    The current position.

Returns:



38
39
40
41
42
43
44
45
46
47
# File 'lib/csv_plus_plus/writer.rb', line 38

def self.writer(options, position)
  output_format = options.output_format
  case output_format
  when ::CSVPlusPlus::Options::OutputFormat::CSV then csv(options, position)
  when ::CSVPlusPlus::Options::OutputFormat::Excel then excel(options, position)
  when ::CSVPlusPlus::Options::OutputFormat::GoogleSheets then google_sheets(options, position)
  when ::CSVPlusPlus::Options::OutputFormat::OpenDocument then open_document(options, position)
  else ::T.absurd(output_format)
  end
end