class Tilia::Dav::SimpleCollection
The SimpleCollection
is used to quickly setup static directory structures. Just create the object with a proper name, and add children to use it.
Attributes
List of childnodes
@var INode[]
Name of this resource
@var string
Public Class Methods
Creates this node
The name of the node must be passed, child nodes can also be passed. This nodes must be instances of INode
@param string name @param INode[] children
# File lib/tilia/dav/simple_collection.rb, line 25 def initialize(name, children = []) @name = name @children = {} children.each do |child| fail(Exception, 'Only instances of Sabre\DAV\INode are allowed to be passed in the children argument') unless child.is_a? INode add_child(child) end end
Public Instance Methods
Adds a new childnode to this collection
@param INode
child @return void
# File lib/tilia/dav/simple_collection.rb, line 38 def add_child(child) @children[child.name] = child end
Returns a child object, by its name.
This method makes use of the getChildren method to grab all the child nodes, and compares the name. Generally its wise to override this, as this can usually be optimized
This method must throw SabreDAVExceptionNotFound if the node does not exist.
@param string name @throws ExceptionNotFound @return INode
# File lib/tilia/dav/simple_collection.rb, line 58 def child(name) return @children[name] if @children.key?(name) fail Exception::NotFound, "File not found: #{name} in '#{name}'" end