Class: Sod::Graph::Node
- Inherits:
-
Struct
- Object
- Struct
- Sod::Graph::Node
- 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
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#ancillary ⇒ Object
Returns the value of attribute ancillary.
-
#children ⇒ Object
Returns the value of attribute children.
-
#description ⇒ Object
Returns the value of attribute description.
-
#handle ⇒ Object
Returns the value of attribute handle.
-
#operation ⇒ Object
Returns the value of attribute operation.
Instance Method Summary collapse
- #call ⇒ Object
- #get_action(*lineage) ⇒ Object
- #get_actions(*lineage, node: self) ⇒ Object
- #get_child(*lineage, node: self) ⇒ Object
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #on(object) ⇒ Object
Constructor Details
#initialize ⇒ Node
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
#actions ⇒ Object
Returns the value of attribute actions
8 9 10 |
# File 'lib/sod/graph/node.rb', line 8 def actions @actions end |
#ancillary ⇒ Object
Returns the value of attribute ancillary
8 9 10 |
# File 'lib/sod/graph/node.rb', line 8 def ancillary @ancillary end |
#children ⇒ Object
Returns the value of attribute children
8 9 10 |
# File 'lib/sod/graph/node.rb', line 8 def children @children end |
#description ⇒ Object
Returns the value of attribute description
8 9 10 |
# File 'lib/sod/graph/node.rb', line 8 def description @description end |
#handle ⇒ Object
Returns the value of attribute handle
8 9 10 |
# File 'lib/sod/graph/node.rb', line 8 def handle @handle end |
#operation ⇒ Object
Returns the value of attribute operation
8 9 10 |
# File 'lib/sod/graph/node.rb', line 8 def operation @operation end |
Instance Method Details
#call ⇒ Object
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 |