module CallableTree::Node::Internal
Attributes
children[W]
strategy[W]
Public Instance Methods
append(*callables)
click to toggle source
# File lib/callable_tree/node/internal.rb, line 12 def append(*callables) clone.tap do |node| node.append!(*callables) end end
append!(*callables)
click to toggle source
# File lib/callable_tree/node/internal.rb, line 18 def append!(*callables) callables .map { |callable| nodeify(callable) } .tap { |nodes| children.push(*nodes) } # Use Array#push for Ruby 2.4 self end
broadcast()
click to toggle source
# File lib/callable_tree/node/internal.rb, line 49 def broadcast if strategy.is_a?(Strategy::Broadcast) self else clone.tap do |node| node.send(:strategy=, Strategy::Broadcast.new) end end end
broadcast!()
click to toggle source
# File lib/callable_tree/node/internal.rb, line 59 def broadcast! self.strategy = Strategy::Broadcast.new unless strategy.is_a?(Strategy::Broadcast) self end
call(input = nil, **options)
click to toggle source
# File lib/callable_tree/node/internal.rb, line 30 def call(input = nil, **options) strategy.call(children, input: input, options: options) end
children()
click to toggle source
# File lib/callable_tree/node/internal.rb, line 8 def children @children ||= [] end
compose()
click to toggle source
# File lib/callable_tree/node/internal.rb, line 64 def compose if strategy.is_a?(Strategy::Compose) self else clone.tap do |node| node.send(:strategy=, Strategy::Compose.new) end end end
compose!()
click to toggle source
# File lib/callable_tree/node/internal.rb, line 74 def compose! self.strategy = Strategy::Compose.new unless strategy.is_a?(Strategy::Compose) self end
match?(_input = nil, **_options)
click to toggle source
# File lib/callable_tree/node/internal.rb, line 26 def match?(_input = nil, **_options) !children.empty? end
seek()
click to toggle source
# File lib/callable_tree/node/internal.rb, line 34 def seek if strategy.is_a?(Strategy::Seek) self else clone.tap do |node| node.send(:strategy=, Strategy::Seek.new) end end end
seek!()
click to toggle source
# File lib/callable_tree/node/internal.rb, line 44 def seek! self.strategy = Strategy::Seek.new unless strategy.is_a?(Strategy::Seek) self end
Private Instance Methods
initialize_copy(_node)
click to toggle source
Calls superclass method
# File lib/callable_tree/node/internal.rb, line 96 def initialize_copy(_node) super self.parent = nil self.children = children.map do |node| node.clone.tap { |new_node| new_node.send(:parent=, self) } end end
nodeify(callable)
click to toggle source
# File lib/callable_tree/node/internal.rb, line 83 def nodeify(callable) if callable.is_a?(Node) callable.clone else External.proxify(callable) end .tap { |node| node.send(:parent=, self) } end
strategy()
click to toggle source
# File lib/callable_tree/node/internal.rb, line 92 def strategy @strategy ||= Strategy::Seek.new end