Class: CSVPlusPlus::Writer::GoogleSheets
Overview
A class that can write a Template
to Google Sheets (via their API)
Instance Attribute Summary
Attributes inherited from Writer
Instance Method Summary collapse
-
#initialize(options, position) ⇒ GoogleSheets
constructor
A new instance of GoogleSheets.
-
#write(template) ⇒ Object
Write a
template
to Google Sheets. -
#write_backup ⇒ Object
Write a backup of the Google Sheet that is about to be written.
Methods included from GoogleApiClient
Constructor Details
#initialize(options, position) ⇒ GoogleSheets
Returns a new instance of GoogleSheets.
16 17 18 19 20 21 |
# File 'lib/csv_plus_plus/writer/google_sheets.rb', line 16 def initialize(, position) super(position) @options = ::T.let(, ::CSVPlusPlus::Options::GoogleSheetsOptions) @reader = ::T.let(::CSVPlusPlus::Reader::GoogleSheets.new(), ::CSVPlusPlus::Reader::GoogleSheets) end |
Instance Method Details
#write(template) ⇒ Object
Write a template
to Google Sheets
27 28 29 30 31 |
# File 'lib/csv_plus_plus/writer/google_sheets.rb', line 27 def write(template) create_sheet! if @options.create_if_not_exists update_cells!(template) end |
#write_backup ⇒ Object
Write a backup of the Google Sheet that is about to be written
35 36 37 |
# File 'lib/csv_plus_plus/writer/google_sheets.rb', line 35 def write_backup drive_client.copy_file(@options.sheet_id) end |