Browse files

Fixing when repeat until but there is no recurrence

  • Loading branch information...
1 parent 369a4ee commit 59a50832723b5ee61f00f9cdbe87e3208da0deee @gabriel committed Dec 31, 2012
View
30 lib/ri_cal/property_value/recurrence_rule.rb
@@ -3,10 +3,10 @@ class PropertyValue
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
#
# RiCal::PropertyValue::RecurrenceRule represents an icalendar Recurrence Rule property value
- # which is defined in
+ # which is defined in
# rfc 2445 section 4.3.10 pp 40-45
class RecurrenceRule < PropertyValue
-
+
autoload :EnumerationSupportMethods, "ri_cal/property_value/recurrence_rule/enumeration_support_methods.rb"
autoload :OccurrenceIncrementer, "ri_cal/property_value/recurrence_rule/occurrence_incrementer.rb"
autoload :Enumerator, "ri_cal/property_value/recurrence_rule/enumerator.rb"
@@ -19,14 +19,14 @@ class RecurrenceRule < PropertyValue
autoload :RecurringYearDay, "ri_cal/property_value/recurrence_rule/recurring_year_day.rb"
autoload :TimeManipulation, "ri_cal/property_value/recurrence_rule/time_manipulation.rb"
autoload :Validations, "ri_cal/property_value/recurrence_rule/validations.rb"
-
+
def initialize(parent, value_hash) # :nodoc:
@by_list_hash = {}
super
init_by_lists
@by_list_hash = nil
end
-
+
def self.convert(parent, value) #:nodoc:
if String === value
result = new(parent, :value => value)
@@ -35,7 +35,7 @@ def self.convert(parent, value) #:nodoc:
end
result
end
-
+
include Validations
include InitializationMethods
include EnumerationSupportMethods
@@ -57,16 +57,16 @@ def value=(string) # :nodoc:
# Set the frequency of the recurrence rule
# freq_value:: a String which should be in %w[SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY YEARLY]
- #
+ #
# This method resets the receivers list of errors
def freq=(freq_value)
reset_errors
@freq = freq_value
end
- # return the frequency of the rule which will be a string
+ # return the frequency of the rule which will be a string
def freq
- @freq.upcase
+ @freq ? @freq.upcase : nil
end
# return the starting week day for the recurrence rule, which for a valid instance will be one of
@@ -82,7 +82,7 @@ def wkst_day # :nodoc:
# Set the starting week day for the recurrence rule, which should be one of
# "SU", "MO", "TU", "WE", "TH", "FR", or "SA" for the instance to be valid.
# The parameter is however case-insensitive.
- #
+ #
# This method resets the receivers list of errors
def wkst=(value)
reset_errors
@@ -91,9 +91,9 @@ def wkst=(value)
end
# Set the count parameter of the recurrence rule, the count value will be converted to an integer using to_i
- #
+ #
# This method resets the receivers list of errors
-
+
def count=(count_value)
reset_errors
@count = count_value
@@ -126,10 +126,10 @@ def interval=(interval_value)
reset_errors
@interval = interval_value
end
-
+
def value #:nodoc:
@value || to_ical
- end
+ end
# Return a string containing the RFC 2445 representation of the recurrence rule
def to_ical
@@ -144,11 +144,11 @@ def to_ical
result << "WKST=#{wkst}" unless wkst == "MO"
result.join(";")
end
-
+
# Predicate to determine if the receiver generates a bounded or infinite set of occurrences
def bounded?
@count || @until
end
end
end
-end
+end
View
2 lib/ri_cal/property_value/recurrence_rule/enumerator.rb
@@ -63,6 +63,8 @@ def result_passes_filters?(result)
end
def next_occurrence
+ return nil unless @incrementer
+
while true
@next_occurrence_count += 1
result = next_time

0 comments on commit 59a5083

Please sign in to comment.