Class: ShellOpts::Ast::Command
- Defined in:
- lib/shellopts/ast/command.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#command ⇒ Object
Optional sub-command (Ast::Command).
-
#options ⇒ Object
readonly
Array of options (Ast::Option).
Attributes inherited from Node
Instance Method Summary collapse
-
#dump(&block) ⇒ Object
:nocov:.
-
#initialize(grammar, name) ⇒ Command
constructor
A new instance of Command.
-
#values ⇒ Object
Array of option or command tuples.
Methods inherited from Node
Constructor Details
#initialize(grammar, name) ⇒ Command
Returns a new instance of Command.
12 13 14 15 16 |
# File 'lib/shellopts/ast/command.rb', line 12 def initialize(grammar, name) super(grammar, name) @options = [] @command = nil end |
Instance Attribute Details
#command ⇒ Object
Optional sub-command (Ast::Command). Initially nil but assigned by the parser
10 11 12 |
# File 'lib/shellopts/ast/command.rb', line 10 def command @command end |
#options ⇒ Object (readonly)
Array of options (Ast::Option). Initially empty but filled out by the parser
6 7 8 |
# File 'lib/shellopts/ast/command.rb', line 6 def @options end |
Instance Method Details
#dump(&block) ⇒ Object
:nocov:
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/shellopts/ast/command.rb', line 24 def dump(&block) super { yield if block_given? puts "options:" indent { .each { |opt| opt.dump } } print "command:" if command puts indent { command.dump } else puts "nil" end } end |
#values ⇒ Object
Array of option or command tuples
19 20 21 |
# File 'lib/shellopts/ast/command.rb', line 19 def values ( + (Array(command || []))).map { |node| node.to_tuple } end |