class FacebookGoogleCalendarSync::GoogleCalendar
Attributes
details[RW]
Public Class Methods
find_calendar(calendar_name)
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 23 def self.find_calendar calendar_name google_calendar_details = find_calendar_details_by_summary calendar_name if google_calendar_details != nil calendar_with_events(google_calendar_details) else nil end end
find_or_create_calendar(calendar_name)
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 18 def self.find_or_create_calendar calendar_name google_calendar_details = find_or_create_calendar_details calendar_name calendar_with_events(google_calendar_details) end
new(details, data)
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 13 def initialize details, data @details = details @data = data end
Private Class Methods
calendar_with_events(google_calendar_details)
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 72 def self.calendar_with_events google_calendar_details calendar = get_calendar google_calendar_details.id GoogleCalendar.new(google_calendar_details, calendar) end
create_calendar_details(calendar_name)
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 77 def self.create_calendar_details calendar_name timezone = find_primary_calendar_details.timeZone create_calendar 'summary' => calendar_name, 'timeZone' => timezone end
find_or_create_calendar_details(calendar_name)
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 82 def self.find_or_create_calendar_details calendar_name google_calendar_details = find_calendar_details_by_summary calendar_name if google_calendar_details == nil logger.info "Creating Google calendar #{calendar_name} with timezone #{timezone}" google_calendar_details = create_calendar_details calendar_name else logger.info "Found existing Google calendar #{calendar_name}" end google_calendar_details end
Public Instance Methods
description()
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 44 def description @details.description end
events()
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 48 def events @data.items end
find_calendar_details(calendar_name)
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 60 def find_calendar_details calendar_name google_calendar_details = find_calendar_details_by_summary calendar_name if google_calendar_details == nil return nil else logger.info "Found existing Google calendar #{calendar_name}" end google_calendar_details end
find_event_by_uid(uid)
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 56 def find_event_by_uid uid events.find{ | event | event.i_cal_uid == uid } end
id()
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 32 def id @details.id end
last_known_event_update()
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 40 def last_known_event_update extract_last_modified_date(description) rescue DateTime.new(0) end
summary()
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 36 def summary @details.summary end
timezone()
click to toggle source
# File lib/facebook_google_calendar_sync/google_calendar.rb, line 52 def timezone @details.timeZone end