Class: Babl::Nodes::Each

Inherits:
Object
  • Object
show all
Defined in:
lib/babl/nodes/each.rb

Instance Method Summary collapse

Instance Method Details

#render(frame) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/babl/nodes/each.rb', line 32

def render(frame)
    collection = frame.object
    unless Enumerable === collection
        raise Errors::RenderingError, "Not enumerable : #{collection.inspect}\n#{frame.formatted_stack}"
    end

    idx = -1
    collection.map do |value|
        frame.move_forward(value, idx += 1) do |new_frame|
            node.render(new_frame)
        end
    end
end