Class: Siteleaf::Collection

Inherits:
Entity
  • Object
show all
Defined in:
lib/siteleaf/collection.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/collection.rb', line 5

def created_at
  @created_at
end

#directoryObject (readonly)

Returns the value of attribute directory.



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

def directory
  @directory
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  @metadata
end

#outputObject

Returns the value of attribute output.



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

def output
  @output
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

Returns the value of attribute permalink.



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

def permalink
  @permalink
end

#site_idObject

Returns the value of attribute site_id.



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

def site_id
  @site_id
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

#user_idObject

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

Instance Method Details

#create_endpointObject



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

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

#documentsObject



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

def documents
  result = Client.get "#{entity_endpoint}/documents"
  result.map { |r| Document.new(r) } if result.is_a? Array
end

#entity_endpointObject



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

def entity_endpoint
  ::File.join(create_endpoint, identifier)
end

#filenameObject



37
38
39
# File 'lib/siteleaf/collection.rb', line 37

def filename
  path
end

#filesObject



28
29
30
31
# File 'lib/siteleaf/collection.rb', line 28

def files
  result = Client.get "#{entity_endpoint}/files"
  result.map { |r| File.new(r) } if result.is_a? Array
end

#identifierObject



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

def identifier
  path
end

#output?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/siteleaf/collection.rb', line 33

def output?
  output == true
end

#siteObject



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

def site
  Site.find(site_id)
end