Class: Alvalaxia::Calendar

Inherits:
Object
  • Object
show all
Defined in:
lib/alvalaxia/calendar.rb

Overview

Gcal4Ruby wrapper class

Instance Method Summary collapse

Constructor Details

#initializeCalendar

Returns a new instance of Calendar.



9
10
11
12
13
14
# File 'lib/alvalaxia/calendar.rb', line 9

def initialize
  config = read_config
  @service = GCal4Ruby::Service.new
  @service.authenticate(config['credentials']['email'], config['credentials']['password'])
  @calendar = GCal4Ruby::Calendar.find(@service, {:id => config['credentials']['email']})
end

Instance Method Details

#create_event(start_date) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/alvalaxia/calendar.rb', line 16

def create_event(start_date)
  event = GCal4Ruby::Event.new(@service)
  event.calendar = @calendar
  event.title = 'SCP Plays Home'
  event.all_day = true
  event.start_time = start_date
  event.end_time = start_date
  event.where = 'Alvalade XXI'
  event.reminder = [{ :minutes => 24*60, :method => 'email' }]
  event.save
end

#delete_all_eventsObject



28
29
30
31
32
33
# File 'lib/alvalaxia/calendar.rb', line 28

def delete_all_events
  current_events = GCal4Ruby::Event.find(@service, 'SCP Plays Home')
  current_events.each do |ev|
    ev.delete
  end
end