class TwistedCaldav::Query

Attributes

child[RW]

Public Class Methods

event( param=nil ) click to toggle source
# File lib/twisted-caldav/query.rb, line 42
def self.event( param=nil )
    self.new.event( param )
end
todo( param=nil ) click to toggle source
# File lib/twisted-caldav/query.rb, line 47
def self.todo( param=nil )
    self.new.todo
end

Public Instance Methods

child=(child) click to toggle source
# File lib/twisted-caldav/query.rb, line 37
def child=(child)
  child.parent = self
  @child = child
end
event(param = nil) click to toggle source
# File lib/twisted-caldav/query.rb, line 21
def event(param = nil)
  self.child = Filter::Component.new("VEVENT")
  if param.is_a? Range
    self.child.time_range(param) 
  elsif param.is_a? String
    self.child.uid(param)
  else
    self.child
  end
end
to_xml(xml = Builder::XmlMarkup.new(:indent => 2)) click to toggle source

TODO: raise error if to_xml is called before child is assigned

# File lib/twisted-caldav/query.rb, line 6
def to_xml(xml = Builder::XmlMarkup.new(:indent => 2))
  xml.instruct!
  xml.tag! "cal:calendar-query", TwistedCaldav::NAMESPACES do
    xml.tag! "dav:prop" do
      xml.tag! "dav:getetag"
      xml.tag! "cal:calendar-data"
    end
    xml.tag! "cal:filter" do
      cal = Filter::Component.new("VCALENDAR", self)
      cal.child = self.child
      cal.build_xml(xml)
    end
  end
end
todo(param = nil) click to toggle source
# File lib/twisted-caldav/query.rb, line 32
def todo(param = nil)
  self.child = Filter::Component.new("VTODO")
  self.child
end