module RiCal::OccurrenceEnumerator
-
©2009 Rick DeNatale
-
All rights reserved. Refer to the file README.txt for the license
OccurrenceEnumerator provides common methods for CalendarComponents that support recurrence i.e. Event, Journal, Todo, and TimezonePeriod
Public Instance Methods
# File lib/ri_cal/occurrence_enumerator.rb, line 206 def after_range?(overlap_range) start = start_time !start || start > overlap_range.last end
# File lib/ri_cal/occurrence_enumerator.rb, line 201 def before_range?(overlap_range) finish = finish_time !finish_time || finish_time < overlap_range.first end
A predicate which determines whether the component has a bounded set of occurrences
# File lib/ri_cal/occurrence_enumerator.rb, line 217 def bounded? enumeration_instance.bounded? end
execute the block for each occurrence
# File lib/ri_cal/occurrence_enumerator.rb, line 212 def each(&block) # :yields: Component enumeration_instance.each(&block) end
return an array of occurrences according to the options parameter. If a component is not bounded, and the number of occurrences to be returned is not constrained by either the :before, or :count options an ArgumentError will be raised.
The components returned will be the same type as the receiver, but will have any recurrence properties (rrule, rdate, exrule, exdate) removed since they are single occurrences, and will have the recurrence-id property set to the occurrences dtstart value. (see RFC 2445 sec 4.8.4.4 pp 107-109)
parameter options:
- :count
-
an integer which limits the number of occurrences returned.
- :overlapping
-
a two element array of Dates, Times, or DateTimes, assumed to be in chronological order. Only occurrences which are either totally or partially within the range will be returned.
# File lib/ri_cal/occurrence_enumerator.rb, line 192 def occurrences(options={}) enumeration_instance.to_a(options) end
# File lib/ri_cal/occurrence_enumerator.rb, line 260 def recurs? @rrule_property && @rrule_property.length > 0 || @rdate_property && @rdate_property.length > 0 end
Return a array whose first element is a UTC DateTime representing the start of the first occurrence, and whose second element is a UTC DateTime representing the end of the last occurrence. If the receiver is not bounded then the second element will be nil.
The purpose of this method is to provide values which may be used as database attributes so that a query can find all occurence enumerating components which may have occurrences within a range of times.
# File lib/ri_cal/occurrence_enumerator.rb, line 229 def zulu_occurrence_range if bounded? all = occurrences first, last = all.first, all.last else first = occurrences(:count => 1).first last = nil end [first.zulu_occurrence_range_start_time, last ? last.zulu_occurrence_range_finish_time : nil] end