Class: Babl::Nodes::Each

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

Instance Method Summary collapse

Instance Method Details

#dependenciesObject



8
9
10
# File 'lib/babl/nodes/each.rb', line 8

def dependencies
    { __each__: node.dependencies }
end

#pinned_dependenciesObject



16
17
18
# File 'lib/babl/nodes/each.rb', line 16

def pinned_dependencies
    node.pinned_dependencies
end

#render(ctx) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/babl/nodes/each.rb', line 20

def render(ctx)
    collection = ctx.object
    unless Enumerable === collection
        raise Errors::RenderingError, "Not enumerable : #{collection}\n#{ctx.formatted_stack}"
    end
    collection.each_with_index.map { |value, idx| node.render(ctx.move_forward(value, idx)) }
end

#schemaObject



12
13
14
# File 'lib/babl/nodes/each.rb', line 12

def schema
    Schema::DynArray.new(node.schema)
end