Class: Cloudpress::Dropbox::File

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudpress/dropbox/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/cloudpress/dropbox/file.rb', line 5

def path
  @path
end

#revisionObject (readonly)

Returns the value of attribute revision.



5
6
7
# File 'lib/cloudpress/dropbox/file.rb', line 5

def revision
  @revision
end

#stateObject (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

#bodyObject



29
30
31
# File 'lib/cloudpress/dropbox/file.rb', line 29

def body
  @body ||= metadown.output
end

#changed?Boolean

Returns:

  • (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_copyObject



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

#metadataObject



25
26
27
# File 'lib/cloudpress/dropbox/file.rb', line 25

def 
  @metadata ||= metadown.
end

#remote_fileObject



17
18
19
# File 'lib/cloudpress/dropbox/file.rb', line 17

def remote_file
  @remote_file ||= Cloudpress.client.connection.get_file(@path)
end

#titleObject



33
34
35
# File 'lib/cloudpress/dropbox/file.rb', line 33

def title
  ['title'] || @path.split('/').last.split('.').first.titleize
end