Class: Acclaim::Command::Parser

Inherits:
Object
  • Object
show all
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.

Since:

  • 0.0.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, commands) ⇒ Parser

Initializes a new command parser, with the given argument array and set of commands to search for.

Since:

  • 0.0.1



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

#argvObject

The argument array to be searched.

Since:

  • 0.0.1



11
12
13
# File 'lib/acclaim/command/parser.rb', line 11

def argv
  @argv
end

#commandsObject

The commands to search for.

Since:

  • 0.0.1



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.

Since:

  • 0.0.1



25
26
27
# File 'lib/acclaim/command/parser.rb', line 25

def parse!
  find_command
end