Class: Siteleaf::SourceFile

Inherits:
Entity
  • Object
show all
Defined in:
lib/siteleaf/source_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, find, #initialize, #save

Constructor Details

This class inherits a constructor from Siteleaf::Entity

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#download_urlObject (readonly)

Returns the value of attribute download_url.



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

def download_url
  @download_url
end

#fileObject

Returns the value of attribute file.



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

def file
  @file
end

#filesizeObject (readonly)

Returns the value of attribute filesize.



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

def filesize
  @filesize
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#shaObject (readonly)

Returns the value of attribute sha.



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

def sha
  @sha
end

#site_idObject

Returns the value of attribute site_id.



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

def site_id
  @site_id
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

#user_idObject (readonly)

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

Instance Method Details

#create_endpointObject



7
8
9
10
11
# File 'lib/siteleaf/source_file.rb', line 7

def create_endpoint
  uri = URI::Parser.new.escape(identifier)
  uri = uri.gsub('[', '%5B').gsub(']', '%5D') # workaround for https://bugs.ruby-lang.org/issues/12235
  ::File.join('sites', site_id, 'source', uri)
end

#entity_endpointObject



13
14
15
# File 'lib/siteleaf/source_file.rb', line 13

def entity_endpoint
  create_endpoint
end

#identifierObject



17
18
19
# File 'lib/siteleaf/source_file.rb', line 17

def identifier
  name
end

#to_fileObject



21
22
23
# File 'lib/siteleaf/source_file.rb', line 21

def to_file
  Client.get("#{entity_endpoint}?download")
end