Class: CalDAV::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/caldav/query.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childObject

Returns the value of attribute child.



3
4
5
# File 'lib/caldav/query.rb', line 3

def child
  @child
end

Class Method Details

.event(param = nil) ⇒ Object



42
43
44
# File 'lib/caldav/query.rb', line 42

def self.event( param=nil )
    self.new.event( param )
end

.todo(param = nil) ⇒ Object



47
48
49
# File 'lib/caldav/query.rb', line 47

def self.todo( param=nil )
    self.new.todo
end

Instance Method Details

#event(param = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/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)) ⇒ Object

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



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/caldav/query.rb', line 6

def to_xml(xml = Builder::XmlMarkup.new(:indent => 2))
  xml.instruct!
  xml.tag! "cal:calendar-query", CalDAV::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) ⇒ Object



32
33
34
35
# File 'lib/caldav/query.rb', line 32

def todo(param = nil)
  self.child = Filter::Component.new("VTODO")
  self.child
end