Module: RiCal::PropertyValue::RecurrenceRule::EnumerationSupportMethods
- Included in:
- RiCal::PropertyValue::RecurrenceRule
- Defined in:
- lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb
Overview
-
©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
Instance Method Summary collapse
-
#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.
-
#by_rule_list(which) ⇒ Object
:nodoc:.
-
#enumerator(component) ⇒ Object
:nodoc:.
-
#exhausted?(count, time) ⇒ Boolean
:nodoc:.
-
#in_same_set?(time1, time2) ⇒ Boolean
:nodoc:.
- #incrementer_from_start_time(start_time) ⇒ Object
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
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 48 49 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 10 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:
86 87 88 89 90 91 92 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 86 def by_rule_list(which) # :nodoc: if @by_list @by_list[which] else nil end end |
#enumerator(component) ⇒ Object
:nodoc:
51 52 53 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 51 def enumerator(component) # :nodoc: Enumerator.for(self, component, by_list[:bysetpos]) end |
#exhausted?(count, time) ⇒ Boolean
:nodoc:
55 56 57 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 55 def exhausted?(count, time) # :nodoc: (@count && count > @count) || (@until && (time > @until)) end |
#in_same_set?(time1, time2) ⇒ Boolean
:nodoc:
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 59 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
94 95 96 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 94 def incrementer_from_start_time(start_time) RecurrenceRule::OccurrenceIncrementer.from_rrule(self, start_time) end |