Class: Eddy::Models::Loop::Repeat
- Inherits:
-
Object
- Object
- Eddy::Models::Loop::Repeat
- Defined in:
- lib/eddy/models/loop/repeat.rb
Overview
Data form a single loop iteration.
Direct Known Subclasses
TransactionSets::TS810::Loops::IT1::Repeat, TransactionSets::TS810::Loops::N1::Repeat, TransactionSets::TS810::Loops::PID::Repeat, TransactionSets::TS810::Loops::SAC::Repeat, TransactionSets::TS850::Loops::N1::Repeat, TransactionSets::TS850::Loops::PO1::Repeat, TransactionSets::TS855::Loops::ACK::Repeat, TransactionSets::TS855::Loops::N1::Repeat, TransactionSets::TS855::Loops::PID::Repeat, TransactionSets::TS855::Loops::PO1::Repeat, TransactionSets::TS856::Loops::HL_Item::Repeat, TransactionSets::TS856::Loops::HL_Order::Repeat, TransactionSets::TS856::Loops::HL_Shipment::Repeat, TransactionSets::TS856::Loops::HL_Tare::Repeat, TransactionSets::TS856::Loops::N1::Repeat, TransactionSets::TS856::Loops::SLN::Repeat
Instance Attribute Summary collapse
-
#components ⇒ Array<Eddy::Models::Segment, Eddy::Models::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::Models::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.
- #repeat {|rep| ... } ⇒ self
Constructor Details
#initialize(store, *components) ⇒ void
All of a Loop's elements need to be declared in its constructor.
19 20 21 22 23 |
# File 'lib/eddy/models/loop/repeat.rb', line 19 def initialize(store, *components) @store = store components.flatten! @components = components || [] end |
Instance Attribute Details
#components ⇒ Array<Eddy::Models::Segment, Eddy::Models::Loop::Base> (readonly)
An array of Segments and/or other Loops.
This is used as a template to populate content
.
10 11 12 |
# File 'lib/eddy/models/loop/repeat.rb', line 10 def components @components end |
#store ⇒ Eddy::Data::Store (readonly)
Returns Data passed down from a Transaction Set.
12 13 14 |
# File 'lib/eddy/models/loop/repeat.rb', line 12 def store @store end |
Instance Method Details
#all_contents ⇒ Array<Eddy::Models::Segment>
Return all contained Segments in a single, flattened array.
28 29 30 31 32 33 34 35 36 37 38 |
# 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 |