Class: FacebookGoogleCalendarSync::EventConverter
- Inherits:
-
Object
- Object
- FacebookGoogleCalendarSync::EventConverter
show all
- Defined in:
- lib/facebook_google_calendar_sync/event_converter.rb
Overview
Converts Facebook event into Google event hash
Constant Summary
collapse
- STATUS_MAPPINGS =
{'NEEDS-ACTION' => 'needsAction', 'ACCEPTED' => 'accepted'}
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(facebook_event, google_calendar_id) ⇒ EventConverter
Returns a new instance of EventConverter.
9
10
11
12
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 9
def initialize facebook_event, google_calendar_id
@facebook_event = facebook_event
@google_calendar_id = google_calendar_id
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 55
def method_missing(method, *args, &block)
if facebook_event.respond_to?(method)
facebook_event.send(method, *args, &block)
else
super
end
end
|
Instance Attribute Details
#facebook_event ⇒ Object
Returns the value of attribute facebook_event.
6
7
8
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 6
def facebook_event
@facebook_event
end
|
#google_calendar_id ⇒ Object
Returns the value of attribute google_calendar_id.
6
7
8
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 6
def google_calendar_id
@google_calendar_id
end
|
Instance Method Details
#attendees ⇒ Object
28
29
30
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 28
def attendees
[{"email"=>google_calendar_id, 'responseStatus' => partstat}]
end
|
#description ⇒ Object
32
33
34
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 32
def description
"#{facebook_event.description}\n\nOrganiser: #{organiser_name}"
end
|
#organiser ⇒ Object
49
50
51
52
53
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 49
def organiser
{
'email' => '[email protected]',
}
end
|
#organiser_name ⇒ Object
44
45
46
47
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 44
def organiser_name
matches = organizer_property.to_s.scan(/CN=(.*):MAILTO:(.*)/).flatten
matches[0]
end
|
#partstat ⇒ Object
36
37
38
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 36
def partstat
STATUS_MAPPINGS[facebook_event.to_s.scan(/PARTSTAT::(.*)/).flatten.first()]
end
|
#to_hash ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 14
def to_hash
{
'summary' => summary,
'start' => date_hash(dtstart),
'end' => date_hash(dtend),
'iCalUID' => uid,
'description' => description,
'location' => location,
'organizer' => organiser,
'attendees' => attendees,
'transparency' => transparency
}
end
|
#transparency ⇒ Object
40
41
42
|
# File 'lib/facebook_google_calendar_sync/event_converter.rb', line 40
def transparency
partstat == 'accepted' ? 'opaque' : 'transparent'
end
|