lib/run_ical.rb in run_ical-0.4.1 vs lib/run_ical.rb in run_ical-0.4.2
- old
+ new
@@ -23,14 +23,19 @@
def generate
description = @program.const_get(:DESCRIPTION)
data = @program.const_get(:DATA)
cal = Icalendar::Calendar.new
cal.x_wr_calname = "#{description} for #{@race_date}"
- start_date_padding = @race_date.sunday? ? 1 : 2
+ start_date_padding = @race_date.saturday? ? 2 : 1
start_date = @race_date - (data.size - start_date_padding).days
- (start_date..@race_date).to_a.each.with_index do |date, index|
+ date_list = (start_date..@race_date).to_a
+ date_list.each.with_index do |date, index|
activity = data[index][:activity]
+ if activity =~ /rest/i && @race_date.saturday? && index == date_list.size - 1
+ activity = data[index + 1][:activity]
+ end
+
cal.event do |e|
e.dtstart = Icalendar::Values::Date.new(date)
e.dtend = Icalendar::Values::Date.new(date)
e.summary = activity
e.ip_class = "PUBLIC"