Class: Babl::Nodes::FixedArray

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

Instance Method Summary collapse

Instance Method Details

#dependenciesObject



13
14
15
# File 'lib/babl/nodes/fixed_array.rb', line 13

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

#optimizeObject



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

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



17
18
19
# File 'lib/babl/nodes/fixed_array.rb', line 17

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

#render(ctx) ⇒ Object



21
22
23
# File 'lib/babl/nodes/fixed_array.rb', line 21

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

#schemaObject



9
10
11
# File 'lib/babl/nodes/fixed_array.rb', line 9

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