Class: NCal2GCal::GoogleCalendar

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ GoogleCalendar

Returns a new instance of GoogleCalendar.



10
11
12
13
14
15
16
17
18
# File 'lib/ncal2gcal/google_calendar.rb', line 10

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})
end

Instance Attribute Details

#calendarObject

Returns the value of attribute calendar.



8
9
10
# File 'lib/ncal2gcal/google_calendar.rb', line 8

def calendar
  @calendar
end

#eventsObject (readonly)

Returns the value of attribute events.



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

def events
  @events
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/ncal2gcal/google_calendar.rb', line 8

def password
  @password
end

#userObject

Returns the value of attribute user.



8
9
10
# File 'lib/ncal2gcal/google_calendar.rb', line 8

def user
  @user
end

Instance Method Details

#del_event(id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ncal2gcal/google_calendar.rb', line 25

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



19
20
21
# File 'lib/ncal2gcal/google_calendar.rb', line 19

def find_event(id)
  return GCal4Ruby::Event.find(@cal, id)
end

#new_eventObject



22
23
24
# File 'lib/ncal2gcal/google_calendar.rb', line 22

def new_event
  return GCal4Ruby::Event.new(@cal)
end