Class: CommandNode

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#descriptionObject (readonly)

Returns the value of attribute description.



10
11
12
# File 'lib/command_node.rb', line 10

def description
  @description
end

#methodObject (readonly)

Returns the value of attribute method.



10
11
12
# File 'lib/command_node.rb', line 10

def method
  @method
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/command_node.rb', line 10

def name
  @name
end

#objObject (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