Module: CallableTree::Node

Included in:
External, Internal
Defined in:
lib/callable_tree/node.rb,
lib/callable_tree/node/root.rb,
lib/callable_tree/node/builder.rb,
lib/callable_tree/node/external.rb,
lib/callable_tree/node/internal.rb,
lib/callable_tree/node/hooks/caller.rb,
lib/callable_tree/node/hooks/matcher.rb,
lib/callable_tree/node/external/builder.rb,
lib/callable_tree/node/external/verbose.rb,
lib/callable_tree/node/hooks/terminator.rb,
lib/callable_tree/node/internal/builder.rb,
lib/callable_tree/node/internal/strategy.rb,
lib/callable_tree/node/internal/strategyable.rb,
lib/callable_tree/node/internal/strategy/seek.rb,
lib/callable_tree/node/internal/strategy/compose.rb,
lib/callable_tree/node/internal/strategy/broadcast.rb

Defined Under Namespace

Modules: Builder, External, Hooks, Internal Classes: Root

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/callable_tree/node.rb', line 5

def parent
  @parent
end

Instance Method Details

#ancestorsObject



11
12
13
14
15
16
17
18
19
# File 'lib/callable_tree/node.rb', line 11

def ancestors
  ::Enumerator.new do |y|
    node = self
    loop do
      y << node
      break unless (node = node.parent)
    end
  end
end

#call(*_inputs, **_options) ⇒ Object



41
42
43
# File 'lib/callable_tree/node.rb', line 41

def call(*_inputs, **_options)
  raise ::CallableTree::Error, 'Not implemented'
end

#depthObject



29
30
31
# File 'lib/callable_tree/node.rb', line 29

def depth
  root? ? 0 : parent.depth + 1
end

#external?Boolean

Returns:

  • (Boolean)

Raises:



53
54
55
# File 'lib/callable_tree/node.rb', line 53

def external?
  raise ::CallableTree::Error, 'Not implemented'
end

#identityObject



25
26
27
# File 'lib/callable_tree/node.rb', line 25

def identity
  self.class
end

#internal?Boolean

Returns:

  • (Boolean)

Raises:



49
50
51
# File 'lib/callable_tree/node.rb', line 49

def internal?
  raise ::CallableTree::Error, 'Not implemented'
end

#match?(*_inputs, **_options) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/callable_tree/node.rb', line 37

def match?(*_inputs, **_options)
  true
end

#outlineObject



33
34
35
# File 'lib/callable_tree/node.rb', line 33

def outline
  raise ::CallableTree::Error, 'Not implemented'
end

#root?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/callable_tree/node.rb', line 7

def root?
  parent.nil?
end

#routesObject



21
22
23
# File 'lib/callable_tree/node.rb', line 21

def routes
  ancestors.map(&:identity)
end

#terminate?(output, *_inputs, **_options) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/callable_tree/node.rb', line 45

def terminate?(output, *_inputs, **_options)
  !output.nil?
end