Class: SheetsAPI::Document
- Inherits:
-
Object
- Object
- SheetsAPI::Document
- Defined in:
- lib/sheetsAPI.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(documentId: nil, documentName: 'unnamed') ⇒ Document
constructor
A new instance of Document.
- #sheet(sheetName) ⇒ Object
Constructor Details
#initialize(documentId: nil, documentName: 'unnamed') ⇒ Document
Returns a new instance of Document.
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/sheetsAPI.rb', line 96 def initialize(documentId: nil, documentName: 'unnamed') if !documentId file = DriveService.create_file(Google::Apis::DriveV3::File.new(mime_type: 'application/vnd.google-apps.spreadsheet', name: documentName)) documentId = file.id a = Google::Apis::DriveV3::Permission.new(type: 'user', role: 'owner', email_address: '[email protected]') puts a.inspect DriveService.(documentId, a, transfer_ownership: true) end @id = documentId @document = SheetService.get_spreadsheet(documentId) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
107 108 109 |
# File 'lib/sheetsAPI.rb', line 107 def id @id end |
Instance Method Details
#sheet(sheetName) ⇒ Object
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/sheetsAPI.rb', line 109 def sheet(sheetName) @sheetName = sheetName sheet = @document.sheets.find{|sheet| sheet.properties.title.downcase == sheetName.downcase} if !sheet createSheet(sheetName) end return Sheet.new(self, sheetName) end |