Class: Babl::Nodes::With
- Inherits:
-
Object
- Object
- Babl::Nodes::With
- Defined in:
- lib/babl/nodes/with.rb
Instance Method Summary collapse
Instance Method Details
#render(frame) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/babl/nodes/with.rb', line 46 def render(frame) # When there is only 0 or 1 input node, we can avoid the allocation of an array value = case nodes.size when 0 rescue_errors(frame) { block.call } when 1 input = nodes.first.render(frame) rescue_errors(frame) { block.call(input) } else inputs = nodes.map { |node| node.render(frame) } rescue_errors(frame) { block.call(*inputs) } end frame.move_forward(value, :__block__) do |new_frame| node.render(new_frame) end end |