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



14
15
16
17
18
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 14

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.



11
12
13
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 11

def default_duration
  @default_duration
end

#occurrence_listObject

Returns the value of attribute occurrence_list.



11
12
13
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 11

def occurrence_list
  @occurrence_list
end

Instance Method Details

#bounded?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 20

def bounded?
  true
end

#empty?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ri_cal/property_value/occurrence_list.rb', line 24

def empty?
  occurrence_list.empty?
end

#next_occurrenceObject



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

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