class Tilia::CalDav::Xml::Request::FreeBusyQueryReport

FreeBusyQueryReport

This class parses the {DAV:}free-busy-query REPORT, as defined in:

tools.ietf.org/html/rfc3253#section-3.8

Attributes

end[RW]

End time of report

@var DateTime|null

start[RW]

Starttime of report

@var DateTime|null

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/free_busy_query_report.rb, line 42
def self.xml_deserialize(reader)
  time_range = "{#{Plugin::NS_CALDAV}}time-range"

  start = nil
  ending = nil

  (reader.parse_inner_tree({}) || []).each do |elem|
    next unless elem['name'] == time_range

    start =  elem['attributes']['start']
    ending = elem['attributes']['end']
  end

  fail Dav::Exception::BadRequest.new('The freebusy report must have a time-range element') if !start && !ending

  start = VObject::DateTimeParser.parse_date_time(start) if start
  ending = VObject::DateTimeParser.parse_date_time(ending) if ending

  result = new
  result.start = start
  result.end = ending

  result
end