Class: Siteleaf::File

Inherits:
Entity
  • Object
show all
Defined in:
lib/siteleaf/file.rb

Instance Attribute Summary collapse

Attributes inherited from Entity

#error, #message

Instance Method Summary collapse

Methods inherited from Entity

all, #attributes, #attributes=, class_name, create, delete, #delete, endpoint, #entity_endpoint, find, #identifier, #initialize, #save

Constructor Details

This class inherits a constructor from Siteleaf::Entity

Instance Attribute Details

#basenameObject (readonly)

Returns the value of attribute basename.



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

def basename
  @basename
end

#collection_pathObject

Returns the value of attribute collection_path.



4
5
6
# File 'lib/siteleaf/file.rb', line 4

def collection_path
  @collection_path
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



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

def content_type
  @content_type
end

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#directoryObject (readonly)

Returns the value of attribute directory.



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

def directory
  @directory
end

#download_urlObject (readonly)

Returns the value of attribute download_url.



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

def download_url
  @download_url
end

#fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/siteleaf/file.rb', line 4

def file
  @file
end

#filenameObject

Returns the value of attribute filename.



4
5
6
# File 'lib/siteleaf/file.rb', line 4

def filename
  @filename
end

#filesizeObject (readonly)

Returns the value of attribute filesize.



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

def filesize
  @filesize
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/siteleaf/file.rb', line 4

def path
  @path
end

#shaObject (readonly)

Returns the value of attribute sha.



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

def sha
  @sha
end

#site_idObject

Returns the value of attribute site_id.



4
5
6
# File 'lib/siteleaf/file.rb', line 4

def site_id
  @site_id
end

#thumbnail_urlObject (readonly)

Returns the value of attribute thumbnail_url.



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

def thumbnail_url
  @thumbnail_url
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

#user_idObject

Returns the value of attribute user_id.



4
5
6
# File 'lib/siteleaf/file.rb', line 4

def user_id
  @user_id
end

Instance Method Details

#collectionObject



15
16
17
# File 'lib/siteleaf/file.rb', line 15

def collection
  Collection.find(collection_identifier)
end

#collection_identifierObject



19
20
21
# File 'lib/siteleaf/file.rb', line 19

def collection_identifier
  collection_path || (directory && directory.match(/_(.*)/).try(:last))
end

#create_endpointObject



7
8
9
# File 'lib/siteleaf/file.rb', line 7

def create_endpoint
  ::File.join("sites", site_id, "collections", collection_identifier, "files")
end

#siteObject



11
12
13
# File 'lib/siteleaf/file.rb', line 11

def site
  Site.find(site_id) if site_id
end

#to_fileObject



23
24
25
# File 'lib/siteleaf/file.rb', line 23

def to_file
  SourceFile.new(site_id: site_id, name: filename).to_file
end