Class: Googlecal::GEvent
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#summary ⇒ Object
Returns the value of attribute summary.
Attributes inherited from Base
#credentials, #default_calendar
Class Method Summary collapse
-
.create(event_params, calendar_id = Base.calendar_id) ⇒ Object
create and save a new event through googles api.
-
.find(event_id, calendar_id = Base.calendar_id) ⇒ Object
find google calendar event by event_id
:event_id:
- Unique event id given by google cal api. - .search(query, calendar_id = Base.calendar_id) ⇒ Object
Instance Method Summary collapse
-
#delete(calendar_id = Base.calendar_id) ⇒ Object
delete event by event.id in googles api DELETES EVENT.
- #id ⇒ Object
-
#initialize(event = nil) ⇒ GEvent
constructor
initialize with a google event instance.
- #save ⇒ Object
- #status ⇒ Object
-
#update(params, calendar_id = Base.calendar_id) ⇒ Object
update google calendar event by event.id.
Methods inherited from Base
#create_event, #delete_event, events, #get_event
Constructor Details
#initialize(event = nil) ⇒ GEvent
initialize with a google event instance
10 11 12 |
# File 'lib/googlecal/gevent.rb', line 10 def initialize(event = nil) @event = event end |
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
4 5 6 |
# File 'lib/googlecal/gevent.rb', line 4 def end_time @end_time end |
#start_time ⇒ Object
Returns the value of attribute start_time.
4 5 6 |
# File 'lib/googlecal/gevent.rb', line 4 def start_time @start_time end |
#summary ⇒ Object
Returns the value of attribute summary.
4 5 6 |
# File 'lib/googlecal/gevent.rb', line 4 def summary @summary end |
Class Method Details
.create(event_params, calendar_id = Base.calendar_id) ⇒ Object
create and save a new event through googles api
52 53 54 55 56 57 58 59 60 |
# File 'lib/googlecal/gevent.rb', line 52 def self.create(event_params, calendar_id = Base.calendar_id) # event creation event = service.insert_event(calendar_id, Google::Apis::CalendarV3::Event.new(event_params)) if event return GEvent.new(event) else return false end end |
.find(event_id, calendar_id = Base.calendar_id) ⇒ Object
find google calendar event by event_id :event_id:
- Unique event id given by google cal api
80 81 82 83 84 85 86 87 88 |
# File 'lib/googlecal/gevent.rb', line 80 def self.find(event_id, calendar_id = Base.calendar_id) # find by google event id begin event = service.get_event(calendar_id, event_id) return event catch e return nil end end |
.search(query, calendar_id = Base.calendar_id) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/googlecal/gevent.rb', line 90 def self.search(query, calendar_id = Base.calendar_id) begin events = service.list_events(calendar_id, q: query) return events catch e return nil end end |
Instance Method Details
#delete(calendar_id = Base.calendar_id) ⇒ Object
delete event by event.id in googles api DELETES EVENT
64 65 66 67 68 69 |
# File 'lib/googlecal/gevent.rb', line 64 def delete(calendar_id = Base.calendar_id) # delete instance of event # update event instance @event = service.delete_event(calendar_id, id) return true end |
#id ⇒ Object
14 15 16 |
# File 'lib/googlecal/gevent.rb', line 14 def id @event.id end |
#save ⇒ Object
47 48 49 |
# File 'lib/googlecal/gevent.rb', line 47 def save update(start: { date_time: start_time }, end: { date_time: end_time }) end |
#status ⇒ Object
43 44 45 |
# File 'lib/googlecal/gevent.rb', line 43 def status @event.status end |
#update(params, calendar_id = Base.calendar_id) ⇒ Object
update google calendar event by event.id
72 73 74 75 76 |
# File 'lib/googlecal/gevent.rb', line 72 def update(params, calendar_id = Base.calendar_id) # delta update # TODO: update calendar event service.update_event(calendar_id, id, @event) end |