Class: Relevant::GoogleCalendar

Inherits:
Object
  • Object
show all
Includes:
Widget
Defined in:
lib/relevant/google_calendar.rb

Constant Summary collapse

Version =
"0.0.2"

Instance Method Summary collapse

Instance Method Details

#calendarObject



55
56
57
# File 'lib/relevant/google_calendar.rb', line 55

def calendar
  @calendar ||= GCal4Ruby::Calendar.find(gcal, :title => options[:calendar]).first
end

#eventsObject



59
60
61
62
# File 'lib/relevant/google_calendar.rb', line 59

def events
  event_options = {'start-min' => Date.today.beginning_of_day.utc.xmlschema, 'start-max' => 6.days.from_now.end_of_day.utc.xmlschema, :calendar => calendar.id}
  @events ||= GCal4Ruby::Event.find(gcal, options[:search], event_options)
end

#events_happening_on(date) ⇒ Object



64
65
66
# File 'lib/relevant/google_calendar.rb', line 64

def events_happening_on(date)
  events.select {|event| event.start_time.to_date <= date && (event.end_time - 1.minute).to_date >= date}
end

#gcalObject



47
48
49
50
51
52
53
# File 'lib/relevant/google_calendar.rb', line 47

def gcal
  return @gcal if defined?(@gcal)
  
  @gcal = GCal4Ruby::Service.new
  @gcal.authenticate(options[:username], options[:password])
  @gcal
end