Class: CSVPlusPlus::Writer::GoogleSheets

Inherits:
BaseWriter
  • Object
show all
Defined in:
lib/csv_plus_plus/writer/google_sheets.rb

Overview

A class that can output a Template to Google Sheets (via their API)

Constant Summary collapse

SPREADSHEET_INFINITY =

XXX it would be nice to raise this but we shouldn’t expand out more than necessary for our data

1000

Instance Attribute Summary

Attributes inherited from BaseWriter

#options

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ GoogleSheets

initialize



18
19
20
21
22
23
# File 'lib/csv_plus_plus/writer/google_sheets.rb', line 18

def initialize(options)
  super(options)

  @sheet_id = options.google.sheet_id
  @sheet_name = options.sheet_name
end

Instance Method Details

#write(template) ⇒ Object

write a template to Google Sheets



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/csv_plus_plus/writer/google_sheets.rb', line 26

def write(template)
  auth!

  save_spreadsheet!
  save_spreadsheet_values!

  create_sheet! if @options.create_if_not_exists

  update_cells!(template)
rescue ::Google::Apis::ClientError => e
  handle_google_error(e)
end