Class GoogleCalendar::Calendar
In: lib/googlecalendar/calendar.rb
Parent: Object

SUMMARY

  This class represents User's Calendar.

How to get this class

  • get calendar list
     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.
    
  • create an instance from calendar’s feed url
     srv = GoogleCalendar::Service.new(MAIL, PASS)
     cal = Calendar.new(srv, FEED)
    

Methods

calendars  

Constants

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

Public Class methods

get user’s calendar list.

[Source]

# 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

[Validate]