Class: GoogleSpreadsheetFetcher::BulkFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/google_spreadsheet_fetcher/bulk_fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(spreadsheet_id, user_id, config: nil, application_name: nil) ⇒ BulkFetcher

Returns a new instance of BulkFetcher.

Parameters:



10
11
12
13
14
15
16
17
# File 'lib/google_spreadsheet_fetcher/bulk_fetcher.rb', line 10

def initialize(spreadsheet_id, user_id, config: nil, application_name: nil)
  @spreadsheet_id = spreadsheet_id
  @user_id = user_id
  @config = config || GoogleSpreadsheetFetcher.config
  @application_name = application_name

  @spreadsheet = nil
end

Instance Method Details

#all_rows_by!(index: nil, sheet_id: nil, title: nil, skip: 0, structured: false) ⇒ Object

Parameters:

  • index (Integer) (defaults to: nil)
  • sheet_id (Integer) (defaults to: nil)
  • title (String) (defaults to: nil)
  • skip (Integer) (defaults to: 0)
  • structured (Boolean) (defaults to: false)


29
30
31
32
# File 'lib/google_spreadsheet_fetcher/bulk_fetcher.rb', line 29

def all_rows_by!(index: nil, sheet_id: nil, title: nil, skip: 0, structured: false)
  sheet = sheet_by!(index: index, sheet_id: sheet_id, title: title)
  sheet_to_array(sheet, skip: skip, structured: structured)
end

#fetchObject



19
20
21
22
# File 'lib/google_spreadsheet_fetcher/bulk_fetcher.rb', line 19

def fetch
  @spreadsheet = service.get_spreadsheet(@spreadsheet_id, fields: 'sheets(properties,data.rowData.values(formattedValue))')
  self
end

#serviceObject



34
35
36
# File 'lib/google_spreadsheet_fetcher/bulk_fetcher.rb', line 34

def service
  @service ||= GoogleSpreadsheetFetcher::SheetsServiceBuilder.new(@user_id, config: @config, application_name: @application_name).build
end