Class: Parameter::ParameterRepository

Inherits:
RubyUtils::Parameter::BaseParameterRepository
  • Object
show all
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 arguments.

Instance Method Summary collapse

Instance Method Details

#define_mappingObject (private)

method to define the input string values that will match a given paramter symbol



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/parameter/parameter_repository.rb', line 38

def define_mapping
  @mapping[:all] = ['-a', '--all']
  @mapping[:coord] = ['-c', '--coord']
  @mapping[:delta] = ['-d', '--delta']
  @mapping[:extreme] = ['-e', '--extreme']
  @mapping[:index] = ['-i', '--index']
  @mapping[:meta] = ['-m', '--meta']
  @mapping[:option] = ['-o', '--options']
  @mapping[:range] = ['-r', '--range']
  @mapping[:section] = ['-s', '--section']
  @mapping[:time] = ['-t', '--time']      
end

#process_argument(arg) ⇒ Object (private)

method to read further argument and process it depending on its content

Parameters:

  • arg (String)

    the given argument

  • unflagged_arguments (Array)

    the argument array



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/parameter/parameter_repository.rb', line 20

def process_argument(arg)
  case arg
    when *@mapping[:all] then create_argument_entry(:all)
    when *@mapping[:coord] then create_two_argument_entry(:coord)
    when *@mapping[:delta] then create_two_argument_entry(:delta)
    when *@mapping[:extreme] then @parameters[:extreme] = true
    when *@mapping[:index] then create_argument_entry(:index)
    when *@mapping[:meta] then @parameters[:meta] = true
    when *@mapping[:option] then create_argument_entry(:option)
    when *@mapping[:range] then create_two_argument_entry(:range)
    when *@mapping[:section] then create_two_argument_entry(:section)
    when *@mapping[:time] then create_two_argument_entry(:time)
    else
      raise_invalid_parameter(arg)
  end
end