Class: Eddy::Loop::Repeat

Inherits:
Object
  • Object
show all
Defined in:
lib/eddy/models/loop/repeat.rb

Overview

Data form a single loop iteration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store, *components) ⇒ void

All of a Loop's elements need to be declared in its constructor.

Parameters:



18
19
20
21
22
# File 'lib/eddy/models/loop/repeat.rb', line 18

def initialize(store, *components)
  @store = store
  components.flatten!
  @components = components || []
end

Instance Attribute Details

#componentsArray<Eddy::Segment, Eddy::Loop::Base> (readonly)

An array of Segments and/or other Loops. This is used as a template to populate content.

Returns:



9
10
11
# File 'lib/eddy/models/loop/repeat.rb', line 9

def components
  @components
end

#storeEddy::Data::Store (readonly)

Returns Data passed down from a Transaction Set.

Returns:



11
12
13
# File 'lib/eddy/models/loop/repeat.rb', line 11

def store
  @store
end

Instance Method Details

#all_contentsArray<Eddy::Segment>

Return all contained Segments in a single, flattened array.

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/eddy/models/loop/repeat.rb', line 27

def all_contents()
  contents = self.content.flatten.map do |c|
    if c.is_a?(Eddy::Loop::Base)
      c.all_contents()
    elsif c.is_a?(Eddy::Segment)
      c
    else
      raise Eddy::Errors::RenderError
    end
  end
  return contents.flatten
end