Class: Cloudsheet::Drive
Instance Attribute Summary
Attributes inherited from Sheet
Instance Method Summary collapse
-
#initialize(hash) ⇒ Drive
constructor
A new instance of Drive.
- #rows ⇒ Object
- #sheet(num) ⇒ Object
Methods inherited from Sheet
Constructor Details
#initialize(hash) ⇒ Drive
Returns a new instance of Drive.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cloudsheet/drive.rb', line 5 def initialize(hash) if hash[:user] and hash[:password] drive = GoogleDrive.login(hash[:user], hash[:password]) elsif hash[:access_token] drive = GoogleDrive.login_with_oauth(hash[:access_token]) else raise "Missing Google Credentials" end if hash[:sheet_key] @workbook = drive.spreadsheet_by_key(hash[:sheet_key]) else raise "Missing sheet key" end if hash[:sheet] @raw_sheet = @workbook.worksheets[hash[:sheet]] else @raw_sheet = @workbook.worksheets[0] end end |
Instance Method Details
#rows ⇒ Object
32 33 34 |
# File 'lib/cloudsheet/drive.rb', line 32 def rows super.drop(1) end |
#sheet(num) ⇒ Object
27 28 29 30 |
# File 'lib/cloudsheet/drive.rb', line 27 def sheet(num) @raw_sheet = @workbook.worksheets[num] self end |