Class: Eddy::Loop::Repeat
- Inherits:
-
Object
- Object
- Eddy::Loop::Repeat
- Defined in:
- lib/eddy/models/loop/repeat.rb
Overview
Data form a single loop iteration.
Instance Attribute Summary collapse
-
#components ⇒ Array<Eddy::Segment, Eddy::Loop::Base>
readonly
An array of Segments and/or other Loops.
-
#store ⇒ Eddy::Data::Store
readonly
Data passed down from a Transaction Set.
Instance Method Summary collapse
-
#all_contents ⇒ Array<Eddy::Segment>
Return all contained Segments in a single, flattened array.
-
#initialize(store, *components) ⇒ void
constructor
All of a Loop's elements need to be declared in its constructor.
Constructor Details
#initialize(store, *components) ⇒ void
All of a Loop's elements need to be declared in its constructor.
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
#components ⇒ Array<Eddy::Segment, Eddy::Loop::Base> (readonly)
An array of Segments and/or other Loops.
This is used as a template to populate content.
9 10 11 |
# File 'lib/eddy/models/loop/repeat.rb', line 9 def components @components end |
#store ⇒ Eddy::Data::Store (readonly)
Returns Data passed down from a Transaction Set.
11 12 13 |
# File 'lib/eddy/models/loop/repeat.rb', line 11 def store @store end |
Instance Method Details
#all_contents ⇒ Array<Eddy::Segment>
Return all contained Segments in a single, flattened array.
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 |