Class: Google::Calendar::Event
- Inherits:
-
Object
- Object
- Google::Calendar::Event
- Defined in:
- lib/google/calendar/event.rb
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
API Reference * developers.google.com/google-apps/calendar/v3/reference/#Events.
-
#creator ⇒ Object
readonly
Returns the value of attribute creator.
-
#end ⇒ Object
Returns the value of attribute end.
-
#etag ⇒ Object
readonly
API Reference * developers.google.com/google-apps/calendar/v3/reference/#Events.
-
#htmlLink ⇒ Object
readonly
API Reference * developers.google.com/google-apps/calendar/v3/reference/#Events.
-
#iCalUID ⇒ Object
readonly
Returns the value of attribute iCalUID.
-
#id ⇒ Object
readonly
API Reference * developers.google.com/google-apps/calendar/v3/reference/#Events.
-
#kind ⇒ Object
readonly
API Reference * developers.google.com/google-apps/calendar/v3/reference/#Events.
-
#organizer ⇒ Object
readonly
Returns the value of attribute organizer.
-
#reminders ⇒ Object
readonly
Returns the value of attribute reminders.
-
#sequence ⇒ Object
readonly
Returns the value of attribute sequence.
-
#start ⇒ Object
Returns the value of attribute start.
-
#status ⇒ Object
readonly
API Reference * developers.google.com/google-apps/calendar/v3/reference/#Events.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#transparency ⇒ Object
readonly
Returns the value of attribute transparency.
-
#updated ⇒ Object
readonly
API Reference * developers.google.com/google-apps/calendar/v3/reference/#Events.
Class Method Summary collapse
- .delete(id) ⇒ Object
-
.get(id) ⇒ Object
- API
-
get GET /calendars/:calendarId/events/eventId.
- .insert(options = {}) ⇒ Object
-
.list(st, et) ⇒ Object
- API
-
list GET /calendars/:calendarId/events.
-
.quickAdd(text) ⇒ Object
- API
-
quickAdd POST /calendars/:calendarId/events/quickAdd.
- .this_month ⇒ Object
- .this_week ⇒ Object
- .this_year ⇒ Object
- .today ⇒ Object
- .tomorrow ⇒ Object
- .yesterday ⇒ Object
Instance Method Summary collapse
-
#delete ⇒ Object
- API
-
delete DELETE /calendars/:calendarId/events/:eventId.
- #fetch ⇒ Object
-
#initialize(options = {}) ⇒ Event
constructor
A new instance of Event.
-
#insert ⇒ Object
- API
-
insert POST /calendars/:calendarId/events.
- #num_of_days ⇒ Object
- #to_hash ⇒ Object
- #to_json ⇒ Object
-
#update ⇒ Object
- API
-
update PUT /calendars/:calendarId/events/:eventId.
Constructor Details
#initialize(options = {}) ⇒ Event
Returns a new instance of Event.
24 25 26 |
# File 'lib/google/calendar/event.rb', line 24 def initialize(={}) update_attributes() end |
Instance Attribute Details
#created ⇒ Object (readonly)
API Reference
* https://developers.google.com/google-apps/calendar/v3/reference/#Events
Supported Google Calendar API (Events)
Method VERB PATH
-------- ------ --------------------------------------
get GET /calendars/:calendarId/events/:eventId
list GET /calendars/:calendarId/events
insert POST /calendars/:calendarId/events
delete DELETE /calendars/:calendarId/events/:eventId
quickAdd POST /calendars/:calendarId/events/quickAdd
update PUT /calendars/:calendarId/events/:eventId
21 22 23 |
# File 'lib/google/calendar/event.rb', line 21 def created @created end |
#creator ⇒ Object (readonly)
Returns the value of attribute creator.
22 23 24 |
# File 'lib/google/calendar/event.rb', line 22 def creator @creator end |
#end ⇒ Object
Returns the value of attribute end.
23 24 25 |
# File 'lib/google/calendar/event.rb', line 23 def end @end end |
#etag ⇒ Object (readonly)
API Reference
* https://developers.google.com/google-apps/calendar/v3/reference/#Events
Supported Google Calendar API (Events)
Method VERB PATH
-------- ------ --------------------------------------
get GET /calendars/:calendarId/events/:eventId
list GET /calendars/:calendarId/events
insert POST /calendars/:calendarId/events
delete DELETE /calendars/:calendarId/events/:eventId
quickAdd POST /calendars/:calendarId/events/quickAdd
update PUT /calendars/:calendarId/events/:eventId
21 22 23 |
# File 'lib/google/calendar/event.rb', line 21 def etag @etag end |
#htmlLink ⇒ Object (readonly)
API Reference
* https://developers.google.com/google-apps/calendar/v3/reference/#Events
Supported Google Calendar API (Events)
Method VERB PATH
-------- ------ --------------------------------------
get GET /calendars/:calendarId/events/:eventId
list GET /calendars/:calendarId/events
insert POST /calendars/:calendarId/events
delete DELETE /calendars/:calendarId/events/:eventId
quickAdd POST /calendars/:calendarId/events/quickAdd
update PUT /calendars/:calendarId/events/:eventId
21 22 23 |
# File 'lib/google/calendar/event.rb', line 21 def htmlLink @htmlLink end |
#iCalUID ⇒ Object (readonly)
Returns the value of attribute iCalUID.
22 23 24 |
# File 'lib/google/calendar/event.rb', line 22 def iCalUID @iCalUID end |
#id ⇒ Object (readonly)
API Reference
* https://developers.google.com/google-apps/calendar/v3/reference/#Events
Supported Google Calendar API (Events)
Method VERB PATH
-------- ------ --------------------------------------
get GET /calendars/:calendarId/events/:eventId
list GET /calendars/:calendarId/events
insert POST /calendars/:calendarId/events
delete DELETE /calendars/:calendarId/events/:eventId
quickAdd POST /calendars/:calendarId/events/quickAdd
update PUT /calendars/:calendarId/events/:eventId
21 22 23 |
# File 'lib/google/calendar/event.rb', line 21 def id @id end |
#kind ⇒ Object (readonly)
API Reference
* https://developers.google.com/google-apps/calendar/v3/reference/#Events
Supported Google Calendar API (Events)
Method VERB PATH
-------- ------ --------------------------------------
get GET /calendars/:calendarId/events/:eventId
list GET /calendars/:calendarId/events
insert POST /calendars/:calendarId/events
delete DELETE /calendars/:calendarId/events/:eventId
quickAdd POST /calendars/:calendarId/events/quickAdd
update PUT /calendars/:calendarId/events/:eventId
21 22 23 |
# File 'lib/google/calendar/event.rb', line 21 def kind @kind end |
#organizer ⇒ Object (readonly)
Returns the value of attribute organizer.
22 23 24 |
# File 'lib/google/calendar/event.rb', line 22 def organizer @organizer end |
#reminders ⇒ Object (readonly)
Returns the value of attribute reminders.
22 23 24 |
# File 'lib/google/calendar/event.rb', line 22 def reminders @reminders end |
#sequence ⇒ Object (readonly)
Returns the value of attribute sequence.
22 23 24 |
# File 'lib/google/calendar/event.rb', line 22 def sequence @sequence end |
#start ⇒ Object
Returns the value of attribute start.
23 24 25 |
# File 'lib/google/calendar/event.rb', line 23 def start @start end |
#status ⇒ Object (readonly)
API Reference
* https://developers.google.com/google-apps/calendar/v3/reference/#Events
Supported Google Calendar API (Events)
Method VERB PATH
-------- ------ --------------------------------------
get GET /calendars/:calendarId/events/:eventId
list GET /calendars/:calendarId/events
insert POST /calendars/:calendarId/events
delete DELETE /calendars/:calendarId/events/:eventId
quickAdd POST /calendars/:calendarId/events/quickAdd
update PUT /calendars/:calendarId/events/:eventId
21 22 23 |
# File 'lib/google/calendar/event.rb', line 21 def status @status end |
#summary ⇒ Object
Returns the value of attribute summary.
23 24 25 |
# File 'lib/google/calendar/event.rb', line 23 def summary @summary end |
#transparency ⇒ Object (readonly)
Returns the value of attribute transparency.
22 23 24 |
# File 'lib/google/calendar/event.rb', line 22 def transparency @transparency end |
#updated ⇒ Object (readonly)
API Reference
* https://developers.google.com/google-apps/calendar/v3/reference/#Events
Supported Google Calendar API (Events)
Method VERB PATH
-------- ------ --------------------------------------
get GET /calendars/:calendarId/events/:eventId
list GET /calendars/:calendarId/events
insert POST /calendars/:calendarId/events
delete DELETE /calendars/:calendarId/events/:eventId
quickAdd POST /calendars/:calendarId/events/quickAdd
update PUT /calendars/:calendarId/events/:eventId
21 22 23 |
# File 'lib/google/calendar/event.rb', line 21 def updated @updated end |
Class Method Details
.delete(id) ⇒ Object
70 71 72 |
# File 'lib/google/calendar/event.rb', line 70 def self.delete(id) self.new(id: id).fetch.delete end |
.get(id) ⇒ Object
- API
-
get
GET /calendars/:calendarId/events/eventId
30 31 32 |
# File 'lib/google/calendar/event.rb', line 30 def self.get(id) self.new(id: id).fetch end |
.insert(options = {}) ⇒ Object
58 59 60 |
# File 'lib/google/calendar/event.rb', line 58 def self.insert(={}) self.new().insert end |
.list(st, et) ⇒ Object
- API
-
list
GET /calendars/:calendarId/events
41 42 43 44 45 46 47 48 |
# File 'lib/google/calendar/event.rb', line 41 def self.list(st, et) params = { calendarId: Calendar.id, orderBy: 'startTime', timeMax: et.to_time.utc.iso8601, timeMin: st.to_time.utc.iso8601, singleEvents: 'True' } request(Calendar.api.events.list, params) end |
.quickAdd(text) ⇒ Object
- API
-
quickAdd
POST /calendars/:calendarId/events/quickAdd
76 77 78 79 |
# File 'lib/google/calendar/event.rb', line 76 def self.quickAdd(text) params = { calendarId: Calendar.id, text: text } request(Calendar.api.events.quick_add, params) end |
.this_month ⇒ Object
132 133 134 135 136 |
# File 'lib/google/calendar/event.rb', line 132 def self.this_month start_time = Date.today.beginning_of_month end_time = Date.today.end_of_month list(start_time, end_time) end |
.this_week ⇒ Object
126 127 128 129 130 |
# File 'lib/google/calendar/event.rb', line 126 def self.this_week start_time = Date.today.beginning_of_week end_time = Date.today.end_of_week list(start_time, end_time) end |
.this_year ⇒ Object
138 139 140 141 142 |
# File 'lib/google/calendar/event.rb', line 138 def self.this_year start_time = Date.today.beginning_of_year end_time = Date.today.end_of_year list(start_time, end_time) end |
.today ⇒ Object
108 109 110 111 112 |
# File 'lib/google/calendar/event.rb', line 108 def self.today start_time = Date.today end_time = Date.tomorrow list(start_time, end_time) end |
.tomorrow ⇒ Object
114 115 116 117 118 |
# File 'lib/google/calendar/event.rb', line 114 def self.tomorrow start_time = Date.tomorrow end_time = Date.tomorrow.tomorrow list(start_time, end_time) end |
.yesterday ⇒ Object
120 121 122 123 124 |
# File 'lib/google/calendar/event.rb', line 120 def self.yesterday start_time = Date.yesterday end_time = Date.today list(start_time, end_time) end |
Instance Method Details
#delete ⇒ Object
- API
-
delete
DELETE /calendars/:calendarId/events/:eventId
64 65 66 67 68 |
# File 'lib/google/calendar/event.rb', line 64 def delete params = { calendarId: Calendar.id, eventId: id } request(Calendar.api.events.delete, params) self end |
#fetch ⇒ Object
34 35 36 37 |
# File 'lib/google/calendar/event.rb', line 34 def fetch params = { calendarId: Calendar.id, eventId: id } request(Calendar.api.events.get, params) end |
#insert ⇒ Object
- API
-
insert
POST /calendars/:calendarId/events
52 53 54 55 56 |
# File 'lib/google/calendar/event.rb', line 52 def insert params = { calendarId: Calendar.id } body = self.to_json request(Calendar.api.events.insert, params, body) end |
#num_of_days ⇒ Object
102 103 104 105 106 |
# File 'lib/google/calendar/event.rb', line 102 def num_of_days start_date = (self.start.date || self.start.dateTime).to_date end_date = (self.end.date || self.end.dateTime ).to_date (end_date - start_date).to_i + 1 end |
#to_hash ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/google/calendar/event.rb', line 90 def to_hash self.instance_variables.inject(Hashie::Mash.new) do |hash, name| key = name.to_s.delete("@").to_sym hash[key] = self.instance_variable_get(name) hash end end |
#to_json ⇒ Object
98 99 100 |
# File 'lib/google/calendar/event.rb', line 98 def to_json self.to_hash.to_json end |
#update ⇒ Object
- API
-
update
PUT /calendars/:calendarId/events/:eventId
83 84 85 86 87 88 |
# File 'lib/google/calendar/event.rb', line 83 def update params = { calendarId: Calendar.id, eventId: id } body = self.to_json request(Calendar.api.events.update, params, body) self end |