Class: CallableTree::Node::Internal::Strategy::Broadcast
- Inherits:
-
Object
- Object
- CallableTree::Node::Internal::Strategy::Broadcast
- Includes:
- CallableTree::Node::Internal::Strategy
- Defined in:
- lib/callable_tree/node/internal/strategy/broadcast.rb
Instance Method Summary collapse
- #call(nodes, *inputs, **options) ⇒ Object
-
#initialize(matchable: true, terminable: false) ⇒ Broadcast
constructor
A new instance of Broadcast.
Methods included from CallableTree::Node::Internal::Strategy
#==, #eql?, #hash, #matchable?, #name, #terminable?
Constructor Details
#initialize(matchable: true, terminable: false) ⇒ Broadcast
Returns a new instance of Broadcast.
10 11 12 13 |
# File 'lib/callable_tree/node/internal/strategy/broadcast.rb', line 10 def initialize(matchable: true, terminable: false) self.matchable = matchable self.terminable = terminable end |
Instance Method Details
#call(nodes, *inputs, **options) ⇒ Object
[View source]
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/callable_tree/node/internal/strategy/broadcast.rb', line 15 def call(nodes, *inputs, **) nodes.each_with_object([]) do |node, outputs| output = (node.call(*inputs, **) if matcher.call(node, *inputs, **)) outputs << output break outputs if terminator.call(node, output, *inputs, **) outputs end end |