Class: PeopleGroup::Connectors::GoogleSheets

Inherits:
Object
  • Object
show all
Defined in:
lib/peoplegroup/connectors/google_sheets.rb

Instance Method Summary collapse

Instance Method Details

#spreadsheet(title) ⇒ GoogleDrive::Spreadsheet|nil

Find a spreadsheet by title.

Parameters:

  • title (String)

    the title of the spreadsheet, must be exact and shared with the service account.

Returns:

  • (GoogleDrive::Spreadsheet|nil)

    the found spreadsheet or nil if no matches were found.



11
12
13
# File 'lib/peoplegroup/connectors/google_sheets.rb', line 11

def spreadsheet(title)
  retry_on_error { session.spreadsheet_by_title(title) }
end

#worksheet(spreadsheet_title, worksheet_title) ⇒ GoogleDrive::Worksheet|nil

Find a worksheet by title within a given spreadsheet.

Parameters:

  • spreadsheet_title (String)

    the title of the spreadsheet, must be exact and shared with the service account.

  • worksheet_title (String)

    the title of the worksheet inside the spreadsheet, must be an exact match.

Returns:

  • (GoogleDrive::Worksheet|nil)

    the found worksheet or nil if no matches were found.



19
20
21
22
# File 'lib/peoplegroup/connectors/google_sheets.rb', line 19

def worksheet(spreadsheet_title, worksheet_title)
  worksheets = retry_on_error { spreadsheet(spreadsheet_title).worksheets }
  worksheets.find { |worksheet| worksheet.title == worksheet_title }
end