Class: Locabulary::JsonCreator::GoogleSpreadsheet

Inherits:
Object
  • Object
show all
Defined in:
lib/locabulary/json_creator.rb

Overview

Responsible for interacting with Google Sheets and retrieiving relevant information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document_key, access_token_fetcher = GoogleAccessTokenFetcher) ⇒ GoogleSpreadsheet

Returns a new instance of GoogleSpreadsheet.



98
99
100
101
102
# File 'lib/locabulary/json_creator.rb', line 98

def initialize(document_key, access_token_fetcher = GoogleAccessTokenFetcher)
  @document_key = document_key
  @access_token = access_token_fetcher.call
  @session = GoogleDrive.(access_token)
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



94
95
96
# File 'lib/locabulary/json_creator.rb', line 94

def access_token
  @access_token
end

#document_keyObject (readonly)

Returns the value of attribute document_key.



94
95
96
# File 'lib/locabulary/json_creator.rb', line 94

def document_key
  @document_key
end

Instance Method Details

#all_rowsObject



104
105
106
# File 'lib/locabulary/json_creator.rb', line 104

def all_rows
  session.spreadsheet_by_key(document_key).worksheets[0].rows
end