Class: CommandParser

Inherits:
Object
  • Object
show all
Defined in:
lib/runnable/command_parser.rb

Overview

Base class to create a command-line parameter parser.

It holds that parameters in a hash and the child has to be the one who return the formatted string according to the standard used.

Direct Known Subclasses

Extended, Gnu

Instance Method Summary collapse

Constructor Details

#initializeCommandParser

Create a new instance of the parser.



26
27
28
# File 'lib/runnable/command_parser.rb', line 26

def initialize
  @params = {}
end

Instance Method Details

#add_param(param, value = nil) ⇒ nil

Add params and value to the params hash to be parsed.

Parameters:

  • param (String)

    Parameter name.

  • value (Object) (defaults to: nil)

    Parameter value.

Returns:

  • (nil)


34
35
36
# File 'lib/runnable/command_parser.rb', line 34

def add_param( param, value = nil )
  @params[param] = value
end

#parseArray

This method is abstract.

This method has to be overwritten in the child

Returns:

  • (Array)


41
42
# File 'lib/runnable/command_parser.rb', line 41

def parse
end