Module: SheetsV4::GoogleExtensions::SheetsService

Included in:
Google::Apis::SheetsV4::SheetsService
Defined in:
lib/sheets_v4/google_extensions/sheets_service.rb

Overview

This module extends the Google::Apis::SheetsV4::SheetsService class to add attributes to the Google::Apis::SheetsV4::Spreadsheet and Google::Apis::SheetsV4::Sheet classes that reference the SheetsService instance used to retrieve them.

Similarly, an attribute is added to the Google::Apis::SheetsV4::Sheet class that references the Google::Apis::SheetsV4::Spreadsheet instance that contains it.

This allows getting the SheetsService object from a spreadsheet or sheet object, making it unnecessary to pass the SheetsService object around with the spreadsheet and its sheets.

Examples:

require 'sheets_v4/google_extensions'
sheets_service = SheetsV4::SheetsService.new
spreadsheet = sheets_service.get_spreadsheet('1nT_q0TrQzC3dLZXuI3K9V5P3mArBVZpVd_vRsOpvcyk')

spreadsheet.sheets_service == sheets_service # => true
spreadsheet.sheets.each do |sheet|
  sheet.sheets_service == sheets_service # => true
  sheet.spreadsheet == spreadsheet # => true
end

Instance Method Summary collapse

Instance Method Details

#get_spreadsheet(spreadsheet_id, include_grid_data, ranges, fields, quota_user, options, &block) ⇒ Google::Apis::SheetsV4::Spreadsheet

Gets an existing spreadsheet

Creates a spreadsheet object by calling the original Google::Apis::SheetsV4::SheetsService#get_spreadsheet method and then does the following:

  • Sets the sheets_service attribute for the returned spreadsheet.
  • Sets the sheets_service and spreadsheet attributes all the sheets contained in the spreadsheet.

See the documentation for Google::Apis::SheetsV4::SheetsService#get_spreadsheet for details on the parameters and return value.

Examples:

Get a spreadsheet object and output new attributes:

require 'sheets_v4'
require 'sheets_v4/google_extensions'

sheets_service = SheetsV4::SheetsService.new
spreadsheet_id = '1nT_q0TrQzC3dLZXuI3K9V5P3mArBVZpVd_vRsOpvcyk'

spreadsheet = sheets_service.get_spreadsheet(spreadsheet_id)

Returns:



# File 'lib/sheets_v4/google_extensions/sheets_service.rb', line 51