Method: FplGsheet::Spreadsheet#initialize
- Defined in:
- lib/fpl_gsheet/spreadsheet.rb
#initialize(spreadsheet_title) ⇒ Spreadsheet
Returns a new instance of Spreadsheet.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fpl_gsheet/spreadsheet.rb', line 11 def initialize(spreadsheet_title) # Authenticate a session with your Service Account if File.file?("client_secret.json") session = GoogleDrive::Session.from_service_account_key("client_secret.json") else credentials = StringIO.new(ENV['GOOGLE_CLIENT_SECRET']) session = GoogleDrive::Session.from_service_account_key(credentials) end # Get the spreadsheet by its title @spreadsheet = session.spreadsheet_by_title(spreadsheet_title) @worksheet = @spreadsheet.worksheets.first # the default @max_row = @worksheet.num_rows @rows_to_add = Array.new end |