class Tilia::VObject::Node
A node is the root class for every element in an iCalendar of vCard object.
Constants
- PROFILE_CALDAV
If this option is set, the validator will operate on iCalendar objects on the assumption that the vcards need to be valid for CalDAV.
This means for example that calendars can only contain objects with identical component types and UIDs.
- PROFILE_CARDDAV
If this option is set, the validator will operate on the vcards on the assumption that the vcards need to be valid for CardDAV.
This means for example that the UID is required, whereas it is not for regular vcards.
- REPAIR
The following constants are used by the validate method.
If
REPAIR
is set, the validator will attempt to repair any broken data (if possible).
Attributes
Sets the overridden iterator.
Note that this is not actually part of the iterator interface
@param [ElementList] $iterator
@return [void]
Reference to the parent object, if this is not the top object.
@return [Node]
Public Class Methods
# File lib/tilia/v_object/node.rb, line 167 def initialize @root = nil end
Public Instance Methods
# File lib/tilia/v_object/node.rb, line 176 def ==(other) return true if other.__id__ == __id__ # check class return false unless self.class == other.class # Instance variables should be the same return false unless instance_variables.sort == other.instance_variables.sort # compare all instance variables instance_variables.each do |var| if var == :@root && instance_variable_get(var) == self # We are our own root return false unless other.instance_variable_get(var) == other else return false unless instance_variable_get(var) == other.instance_variable_get(var) end end true end
Gets an item through ArrayAccess.
This method just forwards the request to the inner iterator
@param [Fixnum] $offset
@return [mixed]
# File lib/tilia/v_object/node.rb, line 137 def [](offset) iterator = self.iterator iterator[offset] end
Sets an item through ArrayAccess.
This method just forwards the request to the inner iterator
@param [Fixnum] $offset @param $value
@return [void]
# File lib/tilia/v_object/node.rb, line 150 def []=(offset, value) iterator = self.iterator iterator[offset] = value end
Sets an item through ArrayAccess.
This method just forwards the request to the inner iterator
@param [Fixnum] $offset
@return [void]
# File lib/tilia/v_object/node.rb, line 162 def delete(offset) iterator = self.iterator iterator.delete(offset) end
Call this method on a document if you're done using it.
It's intended to remove all circular references, so PHP can easily clean it up.
@return [void]
# File lib/tilia/v_object/node.rb, line 61 def destroy @parent = nil @root = nil end
# File lib/tilia/v_object/node.rb, line 171 def each iterator = self.iterator iterator.each { |i| yield(i) } end
Returns the iterator for this object.
@return [ElementList]
# File lib/tilia/v_object/node.rb, line 93 def iterator return @iterator if @iterator ElementList.new([self]) end
This method returns an array, with the representation as it should be encoded in JSON. This is used to create jCard or jCal documents.
@return [array]
# File lib/tilia/v_object/node.rb, line 43 def json_serialize end
Checks if an item exists through ArrayAccess.
This method just forwards the request to the inner iterator
@param [Fixnum] $offset
@return [Boolean]
# File lib/tilia/v_object/node.rb, line 125 def key?(offset) iterator = self.iterator iterator.key?(offset) end
Serializes the node into a mimedir format.
@return [String]
# File lib/tilia/v_object/node.rb, line 36 def serialize end
Returns the number of elements.
@return [Fixnum]
# File lib/tilia/v_object/node.rb, line 111 def size it = iterator it.size end
Validates the node for correctness.
The following options are supported:
Node::REPAIR - May attempt to automatically repair the problem.
This method returns an array with detected problems. Every element has the following properties:
* level - problem level. * message - A human-readable string describing the issue. * node - A reference to the problematic node.
The level means:
1 - The issue was repaired (only happens if REPAIR was turned on) 2 - An inconsequential issue 3 - A severe issue.
@param [Fixnum] options
@return [array]
# File lib/tilia/v_object/node.rb, line 86 def validate(_options = 0) [] end
This method serializes the data into XML. This is used to create xCard or xCal documents.
@param [XmlWriter] writer XML writer.
@return [void]
# File lib/tilia/v_object/node.rb, line 52 def xml_serialize(writer) end