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