Class: FacebookGoogleCalendarSync::EventConverter
- Inherits:
-
Object
- Object
- FacebookGoogleCalendarSync::EventConverter
- Defined in:
- lib/facebook_google_calendar_sync/event_converter.rb
Constant Summary collapse
- STATUS_MAPPINGS =
{'NEEDS-ACTION' => 'needsAction', 'ACCEPTED' => 'accepted'}
Instance Attribute Summary collapse
-
#facebook_event ⇒ Object
Returns the value of attribute facebook_event.
-
#google_calendar_id ⇒ Object
Returns the value of attribute google_calendar_id.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Instance Method Summary collapse
- #attendees ⇒ Object
- #created ⇒ Object
- #description ⇒ Object
-
#initialize(facebook_event, google_calendar_id, timezone) ⇒ EventConverter
constructor
A new instance of EventConverter.
- #last_modified ⇒ Object
- #organiser ⇒ Object
- #organiser_name ⇒ Object
- #partstat ⇒ Object
- #summary ⇒ Object
- #to_hash ⇒ Object
- #transparency ⇒ Object
- #uid ⇒ Object
Constructor Details
#initialize(facebook_event, google_calendar_id, timezone) ⇒ EventConverter
Returns a new instance of EventConverter.
8 9 10 11 12 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 8 def initialize facebook_event, google_calendar_id, timezone @facebook_event = facebook_event @google_calendar_id = google_calendar_id @timezone = timezone end |
Instance Attribute Details
#facebook_event ⇒ Object
Returns the value of attribute facebook_event.
5 6 7 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 5 def facebook_event @facebook_event end |
#google_calendar_id ⇒ Object
Returns the value of attribute google_calendar_id.
5 6 7 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 5 def google_calendar_id @google_calendar_id end |
#timezone ⇒ Object
Returns the value of attribute timezone.
5 6 7 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 5 def timezone @timezone end |
Instance Method Details
#attendees ⇒ Object
44 45 46 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 44 def attendees [{"email"=>google_calendar_id, 'responseStatus' => partstat}] end |
#created ⇒ Object
26 27 28 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 26 def created facebook_event.created end |
#description ⇒ Object
48 49 50 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 48 def description "#{facebook_event.description}\n\nOrganiser: #{organiser_name}" end |
#last_modified ⇒ Object
18 19 20 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 18 def last_modified facebook_event.last_modified.convert_time_zone(timezone) end |
#organiser ⇒ Object
65 66 67 68 69 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 65 def organiser { 'email' => '[email protected]', } end |
#organiser_name ⇒ Object
60 61 62 63 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 60 def organiser_name matches = facebook_event.organizer_property.to_s.scan(/CN=(.*):MAILTO:(.*)/).flatten matches[0] end |
#partstat ⇒ Object
52 53 54 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 52 def partstat STATUS_MAPPINGS[facebook_event.to_s.scan(/PARTSTAT::(.*)/).flatten.first()] end |
#summary ⇒ Object
22 23 24 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 22 def summary facebook_event.summary end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 30 def to_hash { 'summary' => facebook_event.summary, 'start' => date_hash(facebook_event.dtstart), 'end' => date_hash(facebook_event.dtend), 'iCalUID' => facebook_event.uid, 'description' => description, 'location' => facebook_event.location, 'organizer' => organiser, 'attendees' => attendees, 'transparency' => transparency } end |
#transparency ⇒ Object
56 57 58 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 56 def transparency partstat == 'accepted' ? 'opaque' : 'transparent' end |
#uid ⇒ Object
14 15 16 |
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 14 def uid facebook_event.uid end |