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.
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
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 |
#fetch ⇒ Object
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 |
#service ⇒ Object
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 |