Class: CoffeeOutside::IcalDispatcher

Inherits:
DispatcherBase show all
Defined in:
lib/coffeeoutside/dispatchers/ical.rb

Instance Attribute Summary

Attributes inherited from DispatcherBase

#end_time, #forecast, #location, #start_time

Instance Method Summary collapse

Methods inherited from DispatcherBase

#debug_method, #initialize, #notify, #production?

Constructor Details

This class inherits a constructor from CoffeeOutside::DispatcherBase

Instance Method Details

#generate_ical_stringObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/coffeeoutside/dispatchers/ical.rb', line 8

def generate_ical_string
  format = "%Y%m%dT%H%M%S"
  tzid = "America/Edmonton"

  # Create a calendar with an event (standard method)
  cal = Icalendar::Calendar.new
  cal.event do |e|
    e.dtstart = Icalendar::Values::DateTime.new @start_time.strftime(format), "tzid" => tzid
    e.dtend = Icalendar::Values::DateTime.new @end_time.strftime(format), "tzid" => tzid
    e.summary = "CoffeeOutside - #{@location.name}"
    e.location = @location.name
  end
  cal.to_ical
end

#notify_debugObject



28
29
30
# File 'lib/coffeeoutside/dispatchers/ical.rb', line 28

def notify_debug
  puts generate_ical_string
end

#notify_productionObject



23
24
25
26
# File 'lib/coffeeoutside/dispatchers/ical.rb', line 23

def notify_production
  i = File.open("yyc.ics", "w")
  i.write(generate_ical_string)
end