Class: Tilia::CalDav::Xml::Request::MkCalendar

Inherits:
Object
  • Object
show all
Includes:
Xml::XmlDeserializable
Defined in:
lib/tilia/cal_dav/xml/request/mk_calendar.rb

Overview

MKCALENDAR parser.

This class parses the MKCALENDAR request, as defined in:

tools.ietf.org/html/rfc4791#section-5.3.1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMkCalendar

initialize instance vars



60
61
62
# File 'lib/tilia/cal_dav/xml/request/mk_calendar.rb', line 60

def initialize
  @properties = {}
end

Instance Attribute Details

#propertiesObject

The list of properties that will be set.



16
17
18
# File 'lib/tilia/cal_dav/xml/request/mk_calendar.rb', line 16

def properties
  @properties
end

Class Method Details

.xml_deserialize(reader) ⇒ Object

The deserialize method is called during xml parsing.

This method is called statictly, this is because in theory this method may be used as a type of constructor, or factory method.

Often you want to return an instance of the current class, but you are free to return other data as well.

You are responsible for advancing the reader to the next element. Not doing anything will result in a never-ending loop.

If you just want to skip parsing for this element altogether, you can just call reader.next

reader.parse_inner_tree will parse the entire sub-tree, and advance to the next element.

Parameters:

  • Reader

    reader

Returns:

  • mixed



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/tilia/cal_dav/xml/request/mk_calendar.rb', line 42

def self.xml_deserialize(reader)
  instance = new

  element_map = reader.element_map
  element_map['{DAV:}prop']   = Dav::Xml::Element::Prop
  element_map['{DAV:}set']    = Tilia::Xml::Element::KeyValue
  elems = reader.parse_inner_tree(element_map)

  elems.each do |elem|
    if elem['name'] == '{DAV:}set'
      instance.properties = instance.properties.merge(elem['value']['{DAV:}prop'])
    end
  end

  instance
end