Sha256: 166c88d40f211c743551de29d47092ceabcecb085e1bbde39fc475fc8e29fdac

Contents?: true

Size: 1.44 KB

Versions: 52

Compression:

Stored size: 1.44 KB

Contents

module RiCal
  class PropertyValue
    class RecurrenceRule < PropertyValue
      #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
      #
      class NegativeSetposEnumerator < Enumerator # :nodoc:

        def initialize(recurrence_rule, component, setpos_list)
          super
          @current_set = []
          @valids = []
        end

        def next_occurrence
          while true
            result = advance
            if result >= start_time
              @count += 1
              return recurrence_rule.exhausted?(@count, result) ? nil : result_occurrence_period(result)
            end
          end
        end
        
        

        def advance
          if @valids.empty?
            fill_set
            @valids = @setpos_list.map {|sp| sp < 0 ? @current_set.length + sp : sp - 1}
            current_time_index = @current_set.index(@start_time)
            if current_time_index
              @valids << current_time_index
            end
            @valids = @valids.uniq.sort
          end
          @current_set[@valids.shift]
        end

        def fill_set
          @current_set = [next_time]
          while true
            self.next_time = @incrementer.next_time(next_time)
            if recurrence_rule.in_same_set?(@current_set.last, next_time)
              @current_set << next_time
            else
              return
            end
          end
        end
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 8 rubygems

Version Path
demingfactor-ri_cal-0.10.0 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
demingfactor-ri_cal-0.9.0 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
ebeigarts-ri_cal-0.8.1 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.0.11 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.5.0 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.5.1 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.5.2 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.5.3 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.6.0 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.6.1 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.6.2 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.6.3 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.7.0 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.7.1 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.7.2 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.7.4 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.7.5 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.7.7 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.8.0 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb
rubyredrick-ri_cal-0.8.1 lib/ri_cal/property_value/recurrence_rule/negative_setpos_enumerator.rb