Class: CallableTree::Node::Internal::Strategy::Seek

Inherits:
Object
  • Object
show all
Includes:
CallableTree::Node::Internal::Strategy
Defined in:
lib/callable_tree/node/internal/strategy/seek.rb

Instance Method Summary collapse

Methods included from CallableTree::Node::Internal::Strategy

#==, #eql?, #hash, #name

Instance Method Details

#call(nodes, *inputs, **options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/callable_tree/node/internal/strategy/seek.rb', line 10

def call(nodes, *inputs, **options)
  nodes
    .lazy
    .select { |node| node.match?(*inputs, **options) }
    .map do |node|
      output = node.call(*inputs, **options)
      terminated = node.terminate?(output, *inputs, **options)
      [output, terminated]
    end
    .select { |_output, terminated| terminated }
    .map { |output, _terminated| output }
    .first
end