Class: Babl::Nodes::FixedArray

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

Constant Summary collapse

EMPTY =
new(Utils::Array::EMPTY)

Instance Method Summary collapse

Instance Method Details

#dependenciesObject



15
16
17
# File 'lib/babl/nodes/fixed_array.rb', line 15

def dependencies
    nodes.map(&:dependencies).reduce(Utils::Hash::EMPTY) { |a, b| Babl::Utils::Hash.deep_merge(a, b) }
end

#optimizeObject



27
28
29
30
31
32
# File 'lib/babl/nodes/fixed_array.rb', line 27

def optimize
    optimized_nodes = nodes.map(&:optimize)
    fixed_array = FixedArray.new(optimized_nodes)
    return fixed_array unless optimized_nodes.all? { |node| Constant === node }
    Constant.new(fixed_array.nodes.map(&:value).freeze, fixed_array.schema)
end

#pinned_dependenciesObject



19
20
21
# File 'lib/babl/nodes/fixed_array.rb', line 19

def pinned_dependencies
    nodes.map(&:pinned_dependencies).reduce(Utils::Hash::EMPTY) { |a, b| Babl::Utils::Hash.deep_merge(a, b) }
end

#render(ctx) ⇒ Object



23
24
25
# File 'lib/babl/nodes/fixed_array.rb', line 23

def render(ctx)
    nodes.map { |node| node.render(ctx) }
end

#schemaObject



11
12
13
# File 'lib/babl/nodes/fixed_array.rb', line 11

def schema
    Schema::FixedArray.new(nodes.map(&:schema))
end