Class: AgCalDAV::Format::Pretty

Inherits:
Raw
  • Object
show all
Defined in:
lib/agcaldav/format.rb

Instance Method Summary collapse

Methods inherited from Raw

#method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class AgCalDAV::Format::Raw

Instance Method Details

#parse_calendar(s) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/agcaldav/format.rb', line 13

def parse_calendar(s)
  result = ""
  xml = REXML::Document.new(s)

  REXML::XPath.each( xml, '//c:calendar-data/', {"c"=>"urn:ietf:params:xml:ns:caldav"} ){|c| result << c.text}
  r = Icalendar.parse(result)
  r
end

#parse_events(vcal) ⇒ Object



44
45
46
# File 'lib/agcaldav/format.rb', line 44

def parse_events( vcal )
  Icalendar.parse(vcal)        
end

#parse_single(body) ⇒ Object



48
49
50
51
# File 'lib/agcaldav/format.rb', line 48

def parse_single( body )
  # FIXME: parse event/todo/vcard
  parse_events( body )
end

#parse_tasks(vcal) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/agcaldav/format.rb', line 33

def parse_tasks( vcal )
  return_tasks = Array.new
  cals = Icalendar.parse(vcal)
  cals.each { |tcal|
    tcal.todos.each { |ttask|  # FIXME
      return_tasks << ttask
    }
  }
  return return_tasks
end

#parse_todo(body) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/agcaldav/format.rb', line 22

def parse_todo( body )
  result = []
  xml = REXML::Document.new( body )
  REXML::XPath.each( xml, '//c:calendar-data/', { "c"=>"urn:ietf:params:xml:ns:caldav"} ){ |c|
    p c.text
    p parse_tasks( c.text )
    result += parse_tasks( c.text )
  }
  return result
end