Class: DocoptCompgen::Node
- Inherits:
-
Object
- Object
- DocoptCompgen::Node
- Defined in:
- lib/docopt_compgen/node.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#subcommands ⇒ Object
readonly
Returns the value of attribute subcommands.
Instance Method Summary collapse
- #add_argument(argument) ⇒ Object
- #add_option(option) ⇒ Object
- #add_subcommand(name) ⇒ Object
-
#initialize(parent = nil) ⇒ Node
constructor
A new instance of Node.
- #options ⇒ Object
Constructor Details
#initialize(parent = nil) ⇒ Node
Returns a new instance of Node.
7 8 9 10 11 12 |
# File 'lib/docopt_compgen/node.rb', line 7 def initialize(parent = nil) @parent = parent @subcommands = {} @options = [] @arguments = [] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
3 4 5 |
# File 'lib/docopt_compgen/node.rb', line 3 def arguments @arguments end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
5 6 7 |
# File 'lib/docopt_compgen/node.rb', line 5 def parent @parent end |
#subcommands ⇒ Object (readonly)
Returns the value of attribute subcommands.
4 5 6 |
# File 'lib/docopt_compgen/node.rb', line 4 def subcommands @subcommands end |
Instance Method Details
#add_argument(argument) ⇒ Object
14 15 16 |
# File 'lib/docopt_compgen/node.rb', line 14 def add_argument(argument) @arguments << argument end |
#add_option(option) ⇒ Object
18 19 20 |
# File 'lib/docopt_compgen/node.rb', line 18 def add_option(option) @options << option end |
#add_subcommand(name) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/docopt_compgen/node.rb', line 30 def add_subcommand(name) if @subcommands[name].nil? @subcommands[name] = Node.new(self) end @subcommands[name] end |
#options ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/docopt_compgen/node.rb', line 22 def = @options if @parent += @parent. end .uniq end |