Class: I18n::Migrations::Backends::GoogleSpreadsheet
- Inherits:
-
Object
- Object
- I18n::Migrations::Backends::GoogleSpreadsheet
- Defined in:
- lib/i18n/migrations/backends/google_spreadsheet.rb
Instance Attribute Summary collapse
-
#sheet ⇒ Object
readonly
Returns the value of attribute sheet.
Instance Method Summary collapse
-
#initialize(locale, spreadsheet_url, key_path) ⇒ GoogleSpreadsheet
constructor
A new instance of GoogleSpreadsheet.
- #sheet_for(name) ⇒ Object
Constructor Details
#initialize(locale, spreadsheet_url, key_path) ⇒ GoogleSpreadsheet
Returns a new instance of GoogleSpreadsheet.
9 10 11 12 13 14 15 |
# File 'lib/i18n/migrations/backends/google_spreadsheet.rb', line 9 def initialize(locale, spreadsheet_url, key_path) @session = GoogleDrive::Session.from_service_account_key(key_path) url = spreadsheet_url || raise("Can't find google spreadsheet for #{locale}") @spreadsheet = @session.spreadsheet_by_url(url) @sheet = sheet_for("Sheet1") end |
Instance Attribute Details
#sheet ⇒ Object (readonly)
Returns the value of attribute sheet.
7 8 9 |
# File 'lib/i18n/migrations/backends/google_spreadsheet.rb', line 7 def sheet @sheet end |
Instance Method Details
#sheet_for(name) ⇒ Object
17 18 19 |
# File 'lib/i18n/migrations/backends/google_spreadsheet.rb', line 17 def sheet_for(name) @spreadsheet.worksheet_by_title(name) || raise("couldn't find worksheet for #{name}") end |