Class: Babl::Nodes::FixedArray
- Inherits:
-
Object
- Object
- Babl::Nodes::FixedArray
- Defined in:
- lib/babl/nodes/fixed_array.rb
Constant Summary collapse
Instance Method Summary collapse
- #dependencies ⇒ Object
- #optimize ⇒ Object
- #pinned_dependencies ⇒ Object
- #render(ctx) ⇒ Object
- #schema ⇒ Object
Instance Method Details
#dependencies ⇒ Object
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 |
#optimize ⇒ Object
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_dependencies ⇒ Object
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 |
#schema ⇒ Object
11 12 13 |
# File 'lib/babl/nodes/fixed_array.rb', line 11 def schema Schema::FixedArray.new(nodes.map(&:schema)) end |