Class | GoogleCalendar::Calendar |
In: |
lib/googlecalendar/calendar.rb
|
Parent: | Object |
This class represents User's Calendar.
srv = GoogleCalendar::Service.new(MAIL, PASS) cal_list = srv.calendars cal_list is a hash of user's calendars. key: a calendar's editable feed url. value: calendar object.
srv = GoogleCalendar::Service.new(MAIL, PASS) cal = Calendar.new(srv, FEED)
ATTRIBUTES | = | { "updated" => ["updated"], "title" => ["title"], "subtitle" => ["subtitle"], "name" => ["author/name"], "email" => ["author/email"], "timezone" => ["gCal:timezone", "value"], "where" => ["gd:where", "valueString"]}.each do |key, val| module_eval( "def #{key}; self.source.root.elements[\"#{val[0]}\"]." + (val.length == 1 ? "text" : "attributes[\"#{val[1]}\"]") + "; end" | defines calendar’s readonly attributes |
get user’s calendar list.
# File lib/googlecalendar/calendar.rb, line 30 def self.calendars(srv) ret = srv.calendar_list list = REXML::Document.new(ret.body) h = {} list.root.elements.each("entry/link") do |e| if e.attributes["rel"] == "alternate" feed = e.attributes["href"] h[feed] = Calendar.new(srv, feed) end end h end