Class: Dropbox::Entry
Overview
A façade over a Dropbox::Session that allows the programmer to interact with Dropbox files in an object-oriented manner. The Dropbox::Entry instance is created by calling the Dropbox::API#entry method:
file = session.file('remote/file.pdf')
dir = session.directory('remote/dir') # these calls are actually identical
Note that no network calls are made; this merely creates a façade that will delegate future calls to the session:
file.move('new/path') # identical to calling session.move('remote/file.pdf', 'new/path')
The internal path is updated as the file is moved and renamed:
file = session.file('first_name.txt')
file.rename('second_name.txt')
file.rename('third_name.txt') # works as the internal path is updated with the first rename
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
The remote path of the file.
Instance Method Summary collapse
-
#copy(dest, options = {}) ⇒ Object
(also: #cp)
Delegates to Dropbox::API#copy.
-
#delete(options = {}) ⇒ Object
(also: #rm)
Delegates to Dropbox::API#delete.
-
#download(options = {}) ⇒ Object
(also: #body)
Delegates to Dropbox::API#download.
-
#initialize(session, path) ⇒ Entry
constructor
:nodoc:.
-
#inspect ⇒ Object
:nodoc:.
-
#link(options = {}) ⇒ Object
Delegates to Dropbox::API#link.
-
#list(options = {}) ⇒ Object
(also: #ls)
Delegates to Dropbox::API#list.
-
#metadata(options = {}) ⇒ Object
(also: #info)
Delegates to Dropbox::API#metadata.
-
#move(dest, options = {}) ⇒ Object
(also: #mv)
Delegates to Dropbox::API#move.
-
#rename(name, options = {}) ⇒ Object
Delegates to Dropbox::API#rename.
-
#thumbnail(*args) ⇒ Object
Delegates to Dropbox::API#thumbnail.
Constructor Details
#initialize(session, path) ⇒ Entry
:nodoc:
29 30 31 32 |
# File 'lib/dropbox/entry.rb', line 29 def initialize(session, path) # :nodoc: @session = session @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
The remote path of the file.
27 28 29 |
# File 'lib/dropbox/entry.rb', line 27 def path @path end |
Instance Method Details
#copy(dest, options = {}) ⇒ Object Also known as: cp
Delegates to Dropbox::API#copy.
67 68 69 |
# File 'lib/dropbox/entry.rb', line 67 def copy(dest, ={}) @session.copy path, dest, end |
#delete(options = {}) ⇒ Object Also known as: rm
Delegates to Dropbox::API#delete.
74 75 76 |
# File 'lib/dropbox/entry.rb', line 74 def delete(={}) @session.delete path, end |
#download(options = {}) ⇒ Object Also known as: body
Delegates to Dropbox::API#download.
81 82 83 |
# File 'lib/dropbox/entry.rb', line 81 def download(={}) @session.download path, end |
#inspect ⇒ Object
:nodoc:
98 99 100 |
# File 'lib/dropbox/entry.rb', line 98 def inspect # :nodoc: "#<#{self.class.to_s} #{path}>" end |
#link(options = {}) ⇒ Object
Delegates to Dropbox::API#link.
94 95 96 |
# File 'lib/dropbox/entry.rb', line 94 def link(={}) @session.link path, end |
#list(options = {}) ⇒ Object Also known as: ls
Delegates to Dropbox::API#list
43 44 45 |
# File 'lib/dropbox/entry.rb', line 43 def list(={}) @session.list path, end |
#metadata(options = {}) ⇒ Object Also known as: info
Delegates to Dropbox::API#metadata.
36 37 38 |
# File 'lib/dropbox/entry.rb', line 36 def (={}) @session. path, end |
#move(dest, options = {}) ⇒ Object Also known as: mv
Delegates to Dropbox::API#move.
50 51 52 53 54 |
# File 'lib/dropbox/entry.rb', line 50 def move(dest, ={}) result = @session.move(path, dest, ) @path = result.path.gsub(/^\//, '') return result end |
#rename(name, options = {}) ⇒ Object
Delegates to Dropbox::API#rename.
59 60 61 62 63 |
# File 'lib/dropbox/entry.rb', line 59 def rename(name, ={}) result = @session.rename(path, name, ) @path = result.path.gsub(/^\//, '') return result end |
#thumbnail(*args) ⇒ Object
Delegates to Dropbox::API#thumbnail.
88 89 90 |
# File 'lib/dropbox/entry.rb', line 88 def thumbnail(*args) @session.thumbnail path, *args end |