Class: Gloo::Shell::CommandNode
- Inherits:
-
Object
- Object
- Gloo::Shell::CommandNode
- Defined in:
- lib/gloo/shell/command_node.rb
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
Get this node's children, given the current shell context.
-
#initialize(name, description: '', method: nil, obj: nil, &children_block) ⇒ CommandNode
constructor
Initialize a command node.
Constructor Details
#initialize(name, description: '', method: nil, obj: nil, &children_block) ⇒ CommandNode
Initialize a command node. Children are supplied lazily via a block, evaluated with the shell's Context whenever they're needed.
19 20 21 22 23 24 25 |
# File 'lib/gloo/shell/command_node.rb', line 19 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.
12 13 14 |
# File 'lib/gloo/shell/command_node.rb', line 12 def description @description end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
12 13 14 |
# File 'lib/gloo/shell/command_node.rb', line 12 def method @method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/gloo/shell/command_node.rb', line 12 def name @name end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
12 13 14 |
# File 'lib/gloo/shell/command_node.rb', line 12 def obj @obj end |
Instance Method Details
#children(context) ⇒ Object
Get this node's children, given the current shell context. Returns an empty array for leaf nodes.
31 32 33 34 35 |
# File 'lib/gloo/shell/command_node.rb', line 31 def children( context ) return [] unless @children_block @children_block.call( context ) end |