class Tilia::CalDav::Xml::Request::CalendarMultiGetReport

CalendarMultiGetReport request parser.

This class parses the {urn:ietf:params:xml:ns:caldav}calendar-multiget REPORT, as defined in:

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

Attributes

content_type[RW]

The mimetype of the content that should be returend. Usually text/calendar.

@var string

expand[RW]

If the calendar data must be expanded, this will contain an array with 2 elements: start and end.

Each may be a DateTime or null.

@var array|null

hrefs[RW]

This is an array with the urls that are being requested.

@var array

properties[RW]

An array with requested properties.

@var array

version[RW]

The version of calendar-data that should be returned. Usually '2.0', referring to iCalendar 2.0.

@var string

Public Class Methods

xml_deserialize(reader) click to toggle source

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.

@param Reader reader @return mixed

# File lib/tilia/cal_dav/xml/request/calendar_multi_get_report.rb, line 63
def self.xml_deserialize(reader)
  elems = reader.parse_inner_tree(
    '{urn:ietf:params:xml:ns:caldav}calendar-data' => Filter::CalendarData,
    '{DAV:}prop'                                   => Tilia::Xml::Element::KeyValue
  )

  new_props = {
    'hrefs'      => [],
    'properties' => []
  }

  elems.each do |elem|
    case elem['name']
    when '{DAV:}prop'
      new_props['properties'] = elem['value'].keys
      if elem['value'].key?("{#{Plugin::NS_CALDAV}}calendar-data")
        new_props = new_props.merge(elem['value']["{#{Plugin::NS_CALDAV}}calendar-data"])
      end
    when '{DAV:}href'
      new_props['hrefs'] << Uri.resolve(reader.context_uri, elem['value'])
    end
  end

  obj = new
  new_props.each do |key, value|
    key = key.underscore
    next unless %w(properties hrefs expand content_type version).include?(key)
    obj.send("#{key}=".to_sym, value)
  end

  obj
end