class Eddy::Models::Loop::Repeat
Data
form a single loop iteration.
Attributes
components[R]
An array of Segments
and/or other Loops. This is used as a template to populate `content`. @return [Array<Eddy::Models::Segment, Eddy::Models::Loop::Base>]
store[R]
@return [Eddy::Data::Store] Data
passed down from a Transaction Set.
Public Class Methods
new(store, *components)
click to toggle source
All of a Loop's elements need to be declared in its constructor.
@param store [Eddy::Data::Store] @param components [Array<Eddy::Models::Loop, Eddy::Models::Segment>] @return [void]
# File lib/eddy/models/loop/repeat.rb, line 19 def initialize(store, *components) @store = store components.flatten! @components = components || [] end
Public Instance Methods
all_contents()
click to toggle source
Return all contained Segments
in a single, flattened array.
@return [Array<Eddy::Models::Segment>]
# File lib/eddy/models/loop/repeat.rb, line 28 def all_contents() contents = self.components.flatten.map do |c| case c when Eddy::Models::Loop::Repeat then c.all_contents() when Eddy::Models::Loop::Base then c.all_contents() when Eddy::Models::Segment then c else raise Eddy::Errors::RenderError end end return contents.flatten end
repeat() { |self| ... }
click to toggle source
@yieldparam [self] rep @return [self]
# File lib/eddy/models/loop/repeat.rb, line 42 def repeat() if block_given? yield(self) else raise Eddy::Errors::Error, "No block given in loop iteration" end return self end