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:.
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
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 50 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 11 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:
87 88 89 90 91 92 93 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 87 def by_rule_list(which) # :nodoc: if @by_list @by_list[which] else nil end end |
#enumerator(component) ⇒ Object
:nodoc:
52 53 54 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 52 def enumerator(component) # :nodoc: Enumerator.for(self, component, by_list[:bysetpos]) end |
#exhausted?(count, time) ⇒ Boolean
:nodoc:
56 57 58 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 56 def exhausted?(count, time) # :nodoc: (@count && count > @count) || (@until && (time > @until)) end |
#in_same_set?(time1, time2) ⇒ Boolean
:nodoc:
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 85 |
# File 'lib/ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb', line 60 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 |