Class: FacebookGoogleCalendarSync::GoogleCalendar

Inherits:
Object
  • Object
show all
Extended by:
GoogleCalendarClient, Logging
Includes:
GoogleCalendarDescription
Defined in:
lib/facebook_google_calendar_sync/google_calendar.rb

Constant Summary

Constants included from GoogleCalendarDescription

FacebookGoogleCalendarSync::GoogleCalendarDescription::DESCRIPTION_MIDDLE, FacebookGoogleCalendarSync::GoogleCalendarDescription::DESCRIPTION_PREFIX, FacebookGoogleCalendarSync::GoogleCalendarDescription::DESCRIPTION_SUFFIX

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

logger

Methods included from GoogleCalendarClient

add_event, configure, create_calendar, find_calendar_details_by_summary, find_primary_calendar_details, get_calendar, get_calendar_list, get_calendar_metadata, update_calendar, update_event

Methods included from GoogleCalendarDescription

#create_description, #extract_last_modified_date

Constructor Details

#initialize(details, data) ⇒ GoogleCalendar

Returns a new instance of GoogleCalendar.



13
14
15
16
# File 'lib/facebook_google_calendar_sync/google_calendar.rb', line 13

def initialize details, data
  @details = details
  @data = data
end

Instance Attribute Details

#detailsObject

Returns the value of attribute details.



11
12
13
# File 'lib/facebook_google_calendar_sync/google_calendar.rb', line 11

def details
  @details
end

Class Method Details

.find_calendar(calendar_name) ⇒ Object



23
24
25
26
27
28
29
30
# 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) ⇒ Object



18
19
20
21
# 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

Instance Method Details

#descriptionObject



44
45
46
# File 'lib/facebook_google_calendar_sync/google_calendar.rb', line 44

def description
  @details.description
end

#eventsObject



48
49
50
# File 'lib/facebook_google_calendar_sync/google_calendar.rb', line 48

def events
  @data.items
end

#find_calendar_details(calendar_name) ⇒ Object



60
61
62
63
64
65
66
67
68
# 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) ⇒ Object



56
57
58
# 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

#idObject



32
33
34
# File 'lib/facebook_google_calendar_sync/google_calendar.rb', line 32

def id
  @details.id
end

#last_known_event_updateObject



40
41
42
# 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

#summaryObject



36
37
38
# File 'lib/facebook_google_calendar_sync/google_calendar.rb', line 36

def summary
  @details.summary
end

#timezoneObject



52
53
54
# File 'lib/facebook_google_calendar_sync/google_calendar.rb', line 52

def timezone
  @details.timeZone
end