Class: Gloo::Shell::CommandNode

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo/shell/command_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/gloo/shell/command_node.rb', line 12

def description
  @description
end

#methodObject (readonly)

Returns the value of attribute method.



12
13
14
# File 'lib/gloo/shell/command_node.rb', line 12

def method
  @method
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/gloo/shell/command_node.rb', line 12

def name
  @name
end

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