Class: GoogleSpreadsheetFetcher::BulkFetcher
- Inherits:
-
Object
- Object
- GoogleSpreadsheetFetcher::BulkFetcher
- Defined in:
- lib/google_spreadsheet_fetcher/bulk_fetcher.rb
Instance Method Summary collapse
- #all_rows_by!(index: nil, sheet_id: nil, title: nil, skip: 0, structured: false) ⇒ Object
- #fetch ⇒ Object
-
#initialize(spreadsheet_id, user_id, config: nil, application_name: nil) ⇒ BulkFetcher
constructor
A new instance of BulkFetcher.
- #service ⇒ Object
Constructor Details
#initialize(spreadsheet_id, user_id, config: nil, application_name: nil) ⇒ BulkFetcher
Returns a new instance of BulkFetcher.
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
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 |
#fetch ⇒ Object
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 |
#service ⇒ Object
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 |