Class: CommandNode
- Inherits:
-
Object
- Object
- CommandNode
- Defined in:
- lib/command_node.rb
Overview
- Author
-
Eric Crane (eric.crane@mac.com)
- Copyright
-
Copyright © 2026 Eric Crane. All rights reserved.
A command node. Represents a command in the command tree.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
Instance Method Summary collapse
- #children(context) ⇒ Object
-
#initialize(name, description: "", method: nil, obj: nil, &children_block) ⇒ CommandNode
constructor
A new instance of CommandNode.
Constructor Details
#initialize(name, description: "", method: nil, obj: nil, &children_block) ⇒ CommandNode
Returns a new instance of CommandNode.
12 13 14 15 16 17 18 |
# File 'lib/command_node.rb', line 12 def initialize( name, description: "", method: nil, obj: nil, &children_block ) @name = name @description = description @method = method @obj = obj @children_block = children_block end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/command_node.rb', line 10 def description @description end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
10 11 12 |
# File 'lib/command_node.rb', line 10 def method @method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/command_node.rb', line 10 def name @name end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
10 11 12 |
# File 'lib/command_node.rb', line 10 def obj @obj end |
Instance Method Details
#children(context) ⇒ Object
20 21 22 23 |
# File 'lib/command_node.rb', line 20 def children( context ) return [] unless @children_block @children_block.call( context ) end |