Class: Acclaim::Command::Parser
- Inherits:
-
Object
- Object
- Acclaim::Command::Parser
- Defined in:
- lib/acclaim/command/parser.rb
Overview
Given an argument array and a list of commands, searches for them among the elements of the array.
Instance Attribute Summary collapse
-
#argv ⇒ Object
The argument array to be searched.
-
#commands ⇒ Object
The commands to search for.
Instance Method Summary collapse
-
#initialize(argv, commands) ⇒ Parser
constructor
Initializes a new command parser, with the given argument array and set of commands to search for.
-
#parse! ⇒ Object
Parses the argument array and returns one of the given commands, if one is found, or
nil
otherwise.
Constructor Details
#initialize(argv, commands) ⇒ Parser
Initializes a new command parser, with the given argument array and set of commands to search for.
18 19 20 21 |
# File 'lib/acclaim/command/parser.rb', line 18 def initialize(argv, commands) self.argv = argv self.commands = commands end |
Instance Attribute Details
#argv ⇒ Object
The argument array to be searched.
11 12 13 |
# File 'lib/acclaim/command/parser.rb', line 11 def argv @argv end |
#commands ⇒ Object
The commands to search for.
14 15 16 |
# File 'lib/acclaim/command/parser.rb', line 14 def commands @commands end |
Instance Method Details
#parse! ⇒ Object
Parses the argument array and returns one of the given commands, if one is found, or nil
otherwise.
25 26 27 |
# File 'lib/acclaim/command/parser.rb', line 25 def parse! find_command end |