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:



7
8
9
10
11
12
13
14
# File 'lib/google_spreadsheet_fetcher/bulk_fetcher.rb', line 7

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)


26
27
28
29
# File 'lib/google_spreadsheet_fetcher/bulk_fetcher.rb', line 26

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



16
17
18
19
# File 'lib/google_spreadsheet_fetcher/bulk_fetcher.rb', line 16

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

#serviceObject



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

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