Class: RiCal::PropertyValue::OccurrenceList::Enumerator

Inherits:
Object
  • Object
show all
Defined in:
lib/ri_cal/property_value/occurrence_list.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(occurrences, component) ⇒ Enumerator

TODO: the component parameter should always be the parent



12
13
14
15
16
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 12

def initialize(occurrences, component) # :nodoc:
  self.occurrence_list = occurrences
  self.default_duration = component.default_duration
  @index = 0
end

Instance Attribute Details

#default_durationObject

Returns the value of attribute default_duration.



9
10
11
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 9

def default_duration
  @default_duration
end

#occurrence_listObject

Returns the value of attribute occurrence_list.



9
10
11
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 9

def occurrence_list
  @occurrence_list
end

Instance Method Details

#bounded?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 18

def bounded?
  true
end

#empty?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 22

def empty?
  occurrence_list.empty?
end

#next_occurrenceObject



26
27
28
29
30
31
32
33
34
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 26

def next_occurrence
  if @index < occurrence_list.length
    result = occurrence_list[@index].occurrence_period(default_duration)
    @index += 1
    result
  else
    nil
  end
end