Class: WrfForecast::ForecastHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/wrf_forecast/forecast/forecast_handler.rb

Overview

This class maintains the data and handler classes which are needed to generate the forecast based on the given data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrf_handler) ⇒ ForecastHandler

initialization

Parameters:

  • wrf_handler (WrfHandler)

    the wrf handler with the input data



17
18
19
20
21
22
23
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 17

def initialize(wrf_handler)
  @repository = WrfForecast::ForecastRepository.new(wrf_handler)
  @threshold_handler = WrfForecast::Threshold::ThresholdHandler.new(@repository)
  @wrf_handler = wrf_handler
   = wrf_handler.data_repository.
  @text = WrfForecast::ForecastText.new(, @repository, @threshold_handler)
end

Instance Attribute Details

#json_converterForecastJsonConverter (readonly, private)

Returns the json converter.

Returns:

  • (ForecastJsonConverter)

    the json converter



50
51
52
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 50

def json_converter
  @json_converter
end

#repositoryForecastRepository (readonly, private)

Returns the repository with the rehashed forecast data.

Returns:



52
53
54
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 52

def repository
  @repository
end

#textForecastText (readonly)

Returns the class creation the forecast text.

Returns:



13
14
15
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 13

def text
  @text
end

#threshold_handlerThresholdHandler (readonly, private)

Returns the handler with the threshold indicators.

Returns:

  • (ThresholdHandler)

    the handler with the threshold indicators



54
55
56
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 54

def threshold_handler
  @threshold_handler
end

#wrf_handlerWrfHandler (readonly, private)

Returns the wrf handler with the input data.

Returns:

  • (WrfHandler)

    the wrf handler with the input data



56
57
58
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 56

def wrf_handler
  @wrf_handler
end

Instance Method Details

#generate_hourly_json_outputString

method to generate a json representing the hourly values of forecast data

Returns:

  • (String)

    the json converted forecast information



35
36
37
38
39
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 35

def generate_hourly_json_output
  @json_converter = WrfForecast::JsonConverter::HourlyForecastJsonConverter.
                    new(@wrf_handler, @repository, @threshold_handler.warnings)
  @json_converter.convert
end

#generate_text_json_outputString

method to generate a json representation of the forecast data

Returns:

  • (String)

    the json converted forecast information



27
28
29
30
31
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 27

def generate_text_json_output
  @json_converter = WrfForecast::JsonConverter::TextForecastJsonConverter.
                    new(@wrf_handler.data_repository, @repository, @threshold_handler.warnings)
  @json_converter.convert
end

#get_warningsHash

method to return the created warnings

Returns:

  • (Hash)

    the hash with the warnings



43
44
45
# File 'lib/wrf_forecast/forecast/forecast_handler.rb', line 43

def get_warnings
  threshold_handler.warnings
end