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.



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

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



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

def actions
  @actions
end

#ancillaryObject

Returns the value of attribute ancillary

Returns:

  • (Object)

    the current value of ancillary



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

def ancillary
  @ancillary
end

#childrenObject

Returns the value of attribute children

Returns:

  • (Object)

    the current value of children



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

def children
  @children
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



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

def description
  @description
end

#handleObject

Returns the value of attribute handle

Returns:

  • (Object)

    the current value of handle



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

def handle
  @handle
end

#operationObject

Returns the value of attribute operation

Returns:

  • (Object)

    the current value of operation



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

def operation
  @operation
end

Instance Method Details

#callObject



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

def call = (operation.call if operation)

#get_action(*lineage) ⇒ Object



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

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

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



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

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

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



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

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

#on(object) ⇒ Object



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

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

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