Class: NextStation::Operation::Node
- Inherits:
-
Object
- Object
- NextStation::Operation::Node
- Defined in:
- lib/next_station/operation/node.rb
Overview
Represents a node in the operation’s execution graph (step or branch).
Instance Attribute Summary collapse
-
#children ⇒ Array<Node>
readonly
Child nodes (for branches or root).
-
#name ⇒ Symbol?
readonly
The name of the step.
-
#options ⇒ Hash
readonly
Execution options.
-
#type ⇒ Symbol
readonly
The node type (:step, :branch, or :root).
Instance Method Summary collapse
-
#add_child(node) ⇒ Object
Adds a child node.
-
#branch(condition) { ... } ⇒ Object
Adds a branch to the node.
-
#initialize(type, name = nil, options = {}) { ... } ⇒ Node
constructor
A new instance of Node.
-
#step(name, options = {}) ⇒ Object
Adds a step to the node.
Constructor Details
#initialize(type, name = nil, options = {}) { ... } ⇒ Node
Returns a new instance of Node.
20 21 22 23 24 25 26 |
# File 'lib/next_station/operation/node.rb', line 20 def initialize(type, name = nil, = {}, &block) @type = type @name = name @options = @children = [] instance_eval(&block) if block_given? end |
Instance Attribute Details
#children ⇒ Array<Node> (readonly)
Returns Child nodes (for branches or root).
14 15 16 |
# File 'lib/next_station/operation/node.rb', line 14 def children @children end |
#name ⇒ Symbol? (readonly)
Returns The name of the step.
10 11 12 |
# File 'lib/next_station/operation/node.rb', line 10 def name @name end |
#options ⇒ Hash (readonly)
Returns Execution options.
12 13 14 |
# File 'lib/next_station/operation/node.rb', line 12 def @options end |
#type ⇒ Symbol (readonly)
Returns The node type (:step, :branch, or :root).
8 9 10 |
# File 'lib/next_station/operation/node.rb', line 8 def type @type end |
Instance Method Details
#add_child(node) ⇒ Object
Adds a child node.
30 31 32 |
# File 'lib/next_station/operation/node.rb', line 30 def add_child(node) @children << node end |