Module: RiCal::PropertyValue::RecurrenceRule::EnumerationSupportMethods

Included in:
RiCal::PropertyValue::RecurrenceRule
Defined in:
lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#adjust_start(start_time) ⇒ Object

if the recurrence rule has a bysetpos part we need to search starting with the first time in the frequency period containing the start time specified by DTSTART



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 8

def adjust_start(start_time) # :nodoc:
  if by_list[:bysetpos]
    case freq
    when "SECONDLY"
      start_time
    when "MINUTELY"
      start_time.change(:seconds => 0)
    when "HOURLY"
      start_time.change(
      :minutes => 0,
      :seconds => start_time.sec
      )
    when "DAILY"
      start_time.change(
      :hour => 0,
      :minutes => start_time.min,
      :seconds => start_time.sec
      )
    when "WEEKLY"
      start_of_week(time)
    when "MONTHLY"
      start_time.change(
      :day => 1,
      :hour => start_time.hour,
      :minutes => start_time.min,
      :seconds => start_time.sec
      )
    when "YEARLY"
      start_time.change(
      :month => 1,
      :day => start_time.day,
      :hour => start_time.hour,
      :minutes => start_time.min,
      :seconds => start_time.sec
      )
    end
  else
    start_time
  end
end

#by_rule_list(which) ⇒ Object

:nodoc:



84
85
86
87
88
89
90
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 84

def by_rule_list(which) # :nodoc:
  if @by_list
    @by_list[which]
  else
    nil
  end
end

#enumerator(component) ⇒ Object

:nodoc:



49
50
51
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 49

def enumerator(component) # :nodoc:
  Enumerator.for(self, component, by_list[:bysetpos])
end

#exhausted?(count, time) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


53
54
55
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 53

def exhausted?(count, time) # :nodoc:
  (@count && count > @count) || (@until && (time > @until))
end

#in_same_set?(time1, time2) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 57

def in_same_set?(time1, time2) # :nodoc:
  case freq
  when "SECONDLY"
    [time1.year, time1.month, time1.day, time1.hour, time1.min, time1.sec] ==
    [time2.year, time2.month, time2.day, time2.hour, time2.min, time2.sec]
  when "MINUTELY"
    [time1.year, time1.month, time1.day, time1.hour, time1.min] ==
    [time2.year, time2.month, time2.day, time2.hour, time2.min]
  when "HOURLY"
    [time1.year, time1.month, time1.day, time1.hour] ==
    [time2.year, time2.month, time2.day, time2.hour]
  when "DAILY"
    [time1.year, time1.month, time1.day] ==
    [time2.year, time2.month, time2.day]
  when "WEEKLY"
    sow1 = start_of_week(time1)
    sow2 = start_of_week(time2)
    [sow1.year, sow1.month, sow1.day] ==
    [sow2.year, sow2.month, sow2.day]
  when "MONTHLY"
    [time1.year, time1.month] ==
    [time2.year, time2.month]
  when "YEARLY"
    time1.year == time2.year
  end
end

#incrementer_from_start_time(start_time) ⇒ Object



92
93
94
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 92

def incrementer_from_start_time(start_time)
  RecurrenceRule::OccurrenceIncrementer.from_rrule(self, start_time)
end