Class: Babl::Operators::Each::EachNode
- Inherits:
-
Object
- Object
- Babl::Operators::Each::EachNode
- Defined in:
- lib/babl/operators/each.rb
Instance Method Summary collapse
- #dependencies ⇒ Object
- #documentation ⇒ Object
-
#initialize(node) ⇒ EachNode
constructor
A new instance of EachNode.
- #pinned_dependencies ⇒ Object
- #render(ctx) ⇒ Object
Constructor Details
#initialize(node) ⇒ EachNode
Returns a new instance of EachNode.
13 14 15 |
# File 'lib/babl/operators/each.rb', line 13 def initialize(node) @node = node end |
Instance Method Details
#dependencies ⇒ Object
17 18 19 |
# File 'lib/babl/operators/each.rb', line 17 def dependencies { __each__: node.dependencies } end |
#documentation ⇒ Object
21 22 23 |
# File 'lib/babl/operators/each.rb', line 21 def documentation [node.documentation] end |
#pinned_dependencies ⇒ Object
25 26 27 |
# File 'lib/babl/operators/each.rb', line 25 def pinned_dependencies node.pinned_dependencies end |
#render(ctx) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/babl/operators/each.rb', line 29 def render(ctx) collection = ctx.object unless collection.is_a?(Enumerable) raise RenderingError, "Object is not enumerable : #{collection.inspect}" end collection.each_with_index.map { |value, idx| node.render(ctx.move_forward(value, idx)) } end |