Class: I18n::Migrations::Backends::GoogleSpreadsheet

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/migrations/backends/google_spreadsheet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.(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

#sheetObject (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