Class: Parameter::ParameterRepository
- Inherits:
-
RubyUtils::Parameter::BaseParameterRepository
- Object
- RubyUtils::Parameter::BaseParameterRepository
- Parameter::ParameterRepository
- Defined in:
- lib/parameter/parameter_repository.rb
Overview
Parameter repository to store the valid parameters of the script. #initialize gets the provided parameters and fills a hash which grants access to the provided parameters and their arguments
Instance Method Summary collapse
-
#define_mapping ⇒ Object
private
method to define the input string values that will match a given paramter symbol.
-
#process_argument(arg) ⇒ Object
private
method to read further argument and process it depending on its content.
-
#set_mode(symbol) ⇒ Object
private
method to check and set the requested working mode.
Instance Method Details
#define_mapping ⇒ Object (private)
method to define the input string values that will match a given paramter symbol
27 28 29 30 31 32 33 |
# File 'lib/parameter/parameter_repository.rb', line 27 def define_mapping @mapping[:index] = ["-i", "--index"] @mapping[:http_request] = ["--request"] @mapping[:source] = ["--source"] @mapping[:http_status] = ["--status"] @mapping[:timestamp] = ["-t", "--timestamp"] end |
#process_argument(arg) ⇒ Object (private)
method to read further argument and process it depending on its content
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/parameter/parameter_repository.rb', line 13 def process_argument(arg) case arg when *@mapping[:http_request] then set_mode(:http_request) when *@mapping[:source] then set_mode(:source) when *@mapping[:http_status] then set_mode(:http_status) when *@mapping[:timestamp] then set_mode(:timestamp) when *@mapping[:index] then create_argument_entry(:index) else raise_invalid_parameter(arg) end nil end |
#set_mode(symbol) ⇒ Object (private)
method to check and set the requested working mode
38 39 40 41 42 43 44 45 |
# File 'lib/parameter/parameter_repository.rb', line 38 def set_mode(symbol) if (!@parameters[:mode]) @parameters[:mode] = symbol else raise ArgumentError, "Error: Mode has already been set.".red end nil end |