Class: Sod::Graph::Node

Inherits:
Struct
  • Object
show all
Defined in:
lib/sod/graph/node.rb

Overview

A generic graph node (and DSL) from which to build multiple lineages with.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNode

Returns a new instance of Node.



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

def initialize(**)
  super
  self[:actions] = Set.new actions
  self[:children] = Set.new children
  self[:ancillary] = Array ancillary
  @depth = 0
  @lineage = []
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions

Returns:

  • (Object)

    the current value of actions



9
10
11
# File 'lib/sod/graph/node.rb', line 9

def actions
  @actions
end

#ancillaryObject

Returns the value of attribute ancillary

Returns:

  • (Object)

    the current value of ancillary



9
10
11
# File 'lib/sod/graph/node.rb', line 9

def ancillary
  @ancillary
end

#childrenObject

Returns the value of attribute children

Returns:

  • (Object)

    the current value of children



9
10
11
# File 'lib/sod/graph/node.rb', line 9

def children
  @children
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



9
10
11
# File 'lib/sod/graph/node.rb', line 9

def description
  @description
end

#handleObject

Returns the value of attribute handle

Returns:

  • (Object)

    the current value of handle



9
10
11
# File 'lib/sod/graph/node.rb', line 9

def handle
  @handle
end

#operationObject

Returns the value of attribute operation

Returns:

  • (Object)

    the current value of operation



9
10
11
# File 'lib/sod/graph/node.rb', line 9

def operation
  @operation
end

Instance Method Details

#callObject



41
# File 'lib/sod/graph/node.rb', line 41

def call = (operation.call if operation)

#get_action(*lineage) ⇒ Object



21
22
23
24
# File 'lib/sod/graph/node.rb', line 21

def get_action *lineage
  handle = lineage.pop
  get_actions(*lineage).find { |action| action.handle.include? handle }
end

#get_actions(*lineage, node: self) ⇒ Object

:reek:DataClump



27
28
29
# File 'lib/sod/graph/node.rb', line 27

def get_actions *lineage, node: self
  lineage.empty? ? node.actions : get(lineage, node, __method__)
end

#get_child(*lineage, node: self) ⇒ Object



31
# File 'lib/sod/graph/node.rb', line 31

def get_child(*lineage, node: self) = lineage.empty? ? node : get(lineage, node, __method__)

#on(object) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/sod/graph/node.rb', line 33

def on(object, *, **, &)
  lineage.clear if depth.zero?

  process(object, *, **)
  visit(&)
  self
end