Class: ShellOpts::Grammar::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/shellopts/grammar/node.rb

Overview

Root class for Grammar objects

Node objects are created by ShellOpts::Grammar.compile that returns a Program object that in turn contains other node objects in a hierarchical structure that reflects the grammar of the program. Only ShellOpts::Grammar.compile should create node objects

Direct Known Subclasses

Command, Option

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ Node

Returns a new instance of Node.



13
14
15
# File 'lib/shellopts/grammar/node.rb', line 13

def initialize(key)
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Key (Symbol) of node. Unique within the enclosing command



11
12
13
# File 'lib/shellopts/grammar/node.rb', line 11

def key
  @key
end

Instance Method Details

#dump(&block) ⇒ Object

:nocov:



18
19
20
21
# File 'lib/shellopts/grammar/node.rb', line 18

def dump(&block) 
  puts key.inspect
  indent { yield } if block_given?
end