Class: WrfForecast::Parameter::ParameterHandler

Inherits:
RubyUtils::Parameter::BaseParameterHandler
  • Object
show all
Defined in:
lib/wrf_forecast/parameter/parameter_handler.rb

Overview

class to seperate the storage of the parameter in a repository entity and checking for valid parameter combination as part of the application logic.

Instance Method Summary collapse

Instance Method Details

#check_parameter_constraintsObject (private)

private method to the specified parameter constraints



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/wrf_forecast/parameter/parameter_handler.rb', line 26

def check_parameter_constraints
  # check mandatory date parameter
  check_mandatory_parameter(:date)

  # check mandatory file parameter
  check_mandatory_parameter(:file)

  # set default value for period if not set
  @repository.parameters[:period] = "24" if (@repository.parameters[:period] == nil)
  nil
end

#initialize_repository(argv) ⇒ Object

method to initialize the correct repository that should be used in this handler

Parameters:

  • argv (Array)

    array of input parameters



12
13
14
# File 'lib/wrf_forecast/parameter/parameter_handler.rb', line 12

def initialize_repository(argv)
  @repository = WrfForecast::Parameter::ParameterRepository.new(argv)
end

#validate_parametersObject (private)

private method with calls of the different validations methods



19
20
21
22
23
# File 'lib/wrf_forecast/parameter/parameter_handler.rb', line 19

def validate_parameters
  check_occurrence(:offset, :period) if (@repository.parameters[:offset])
  check_occurrence(:aggregate, :json) if (@repository.parameters[:aggregate])
  nil
end