Class: Outlook2GCal::GoogleCalendar

Inherits:
Object
  • Object
show all
Defined in:
lib/outlook2gcal/google_calendar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ GoogleCalendar

Returns a new instance of GoogleCalendar.



11
12
13
14
15
16
17
18
19
20
# File 'lib/outlook2gcal/google_calendar.rb', line 11

def initialize(params)
  @user = params[:gmail_user]
  @password = params[:gmail_password]
  @calendar = params[:gmail_calendar] || "LotusNotes"
  
  @service = GCal4Ruby::Service.new
  @service.authenticate(@user, @password )
  @cal = GCal4Ruby::Calendar.find(@service, @calendar, {:scope => :first})[0]
        
end

Instance Attribute Details

#calendarObject

Returns the value of attribute calendar.



9
10
11
# File 'lib/outlook2gcal/google_calendar.rb', line 9

def calendar
  @calendar
end

#eventsObject (readonly)

Returns the value of attribute events.



10
11
12
# File 'lib/outlook2gcal/google_calendar.rb', line 10

def events
  @events
end

#passwordObject

Returns the value of attribute password.



9
10
11
# File 'lib/outlook2gcal/google_calendar.rb', line 9

def password
  @password
end

#userObject

Returns the value of attribute user.



9
10
11
# File 'lib/outlook2gcal/google_calendar.rb', line 9

def user
  @user
end

Instance Method Details

#del_event(id) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/outlook2gcal/google_calendar.rb', line 29

def del_event(id)
  begin
    event = find_event(id) 
    if event 
      return event.delete unless event == []
    end
  rescue  StandardError => e 
     print 'X'
     $logger.error DateTime.now.to_s
     $logger.error id
     $logger.error e 
  end
  return false
end

#find_event(id) ⇒ Object



21
22
23
# File 'lib/outlook2gcal/google_calendar.rb', line 21

def find_event(id)
  return GCal4Ruby::Event.find(@service, {:id=>id}, {:calendar=>@calendar})
end

#new_eventObject



24
25
26
27
28
# File 'lib/outlook2gcal/google_calendar.rb', line 24

def new_event
  event = GCal4Ruby::Event.new(@service)
  event.calendar = @cal
  event
end