Class: Cloudpress::Dropbox::File
- Inherits:
-
Object
- Object
- Cloudpress::Dropbox::File
- Defined in:
- lib/cloudpress/dropbox/file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #body ⇒ Object
- #changed? ⇒ Boolean
- #import! ⇒ Object
-
#initialize(path, revision, state) ⇒ File
constructor
A new instance of File.
- #local_copy ⇒ Object
- #metadata ⇒ Object
- #remote_file ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(path, revision, state) ⇒ File
Returns a new instance of File.
7 8 9 10 11 |
# File 'lib/cloudpress/dropbox/file.rb', line 7 def initialize(path, revision, state) @path = path @revision = revision @state = state end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/cloudpress/dropbox/file.rb', line 5 def path @path end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
5 6 7 |
# File 'lib/cloudpress/dropbox/file.rb', line 5 def revision @revision end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'lib/cloudpress/dropbox/file.rb', line 5 def state @state end |
Instance Method Details
#body ⇒ Object
29 30 31 |
# File 'lib/cloudpress/dropbox/file.rb', line 29 def body @body ||= .output end |
#changed? ⇒ Boolean
37 38 39 |
# File 'lib/cloudpress/dropbox/file.rb', line 37 def changed? !persisted? || revision_changed? end |
#import! ⇒ Object
13 14 15 |
# File 'lib/cloudpress/dropbox/file.rb', line 13 def import! local_copy.update_from_dropbox(self) if changed? end |
#local_copy ⇒ Object
21 22 23 |
# File 'lib/cloudpress/dropbox/file.rb', line 21 def local_copy @local_copy ||= Cloudpress::Post.where(file_path: @path).first_or_initialize end |
#metadata ⇒ Object
25 26 27 |
# File 'lib/cloudpress/dropbox/file.rb', line 25 def @metadata ||= . end |
#remote_file ⇒ Object
17 18 19 |
# File 'lib/cloudpress/dropbox/file.rb', line 17 def remote_file @remote_file ||= Cloudpress.client.connection.get_file(@path) end |
#title ⇒ Object
33 34 35 |
# File 'lib/cloudpress/dropbox/file.rb', line 33 def title ['title'] || @path.split('/').last.split('.').first.titleize end |