Method: GoogleDrive::Session#file_by_title
- Defined in:
- lib/google_drive/session.rb
#file_by_title(title) ⇒ Object
Returns a file (including a spreadsheet and a folder) whose title exactly matches title.
Returns an instance of GoogleDrive::File or its subclass (GoogleDrive::Spreadsheet, GoogleDrive::Collection). Returns nil if not found. If multiple files with the title are found, returns one of them.
If given an Array, traverses collections by title. e.g.
session.file_by_title(["myfolder", "mysubfolder/even/w/slash", "myfile"])
203 204 205 206 207 208 209 |
# File 'lib/google_drive/session.rb', line 203 def file_by_title(title) if title.is_a?(Array) root_collection.file_by_title(title) else files(q: ['name = ?', title], page_size: 1)[0] end end |