Class: WrfForecast::Threshold::ThresholdHandler
- Inherits:
-
Object
- Object
- WrfForecast::Threshold::ThresholdHandler
- Defined in:
- lib/wrf_forecast/threshold/threshold_handler.rb
Overview
This class maintains the different threshold classes and initializes them with the data of the forecast repository.
Instance Attribute Summary collapse
-
#rain_threshold ⇒ RainThreshold
readonly
The class holding the rain thresholds.
-
#temperature_threshold ⇒ TemperatureThreshold
readonly
The class holding the temperature thresholds.
-
#warnings ⇒ Hash
readonly
The mapping of measurand and triggered thresholds for the current forecast.
-
#wind_threshold ⇒ WindThreshold
readonly
The class holding the wind thresholds.
Instance Method Summary collapse
-
#collect_active_thresholds ⇒ Object
private
method to collect all overstepped thresholds indicating significant weather.
-
#collect_thresholds_for(threshold) ⇒ Object
private
method to collect the overstepped thresholds for the given measurand threshold.
-
#initialize(forecast_repository) ⇒ ThresholdHandler
constructor
initialization.
Constructor Details
#initialize(forecast_repository) ⇒ ThresholdHandler
initialization
22 23 24 25 26 27 28 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 22 def initialize(forecast_repository) data = forecast_repository.forecast_data @temperature_threshold = WrfForecast::Threshold::TemperatureThreshold.new(data[:air_temperature]) @wind_threshold = WrfForecast::Threshold::WindThreshold.new(data[:wind_speed]) @rain_threshold = WrfForecast::Threshold::RainThreshold.new(forecast_repository.hourly_rain) collect_active_thresholds end |
Instance Attribute Details
#rain_threshold ⇒ RainThreshold (readonly)
Returns the class holding the rain thresholds.
16 17 18 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 16 def rain_threshold @rain_threshold end |
#temperature_threshold ⇒ TemperatureThreshold (readonly)
Returns the class holding the temperature thresholds.
12 13 14 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 12 def temperature_threshold @temperature_threshold end |
#warnings ⇒ Hash (readonly)
Returns the mapping of measurand and triggered thresholds for the current forecast.
18 19 20 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 18 def warnings @warnings end |
#wind_threshold ⇒ WindThreshold (readonly)
Returns the class holding the wind thresholds.
14 15 16 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 14 def wind_threshold @wind_threshold end |
Instance Method Details
#collect_active_thresholds ⇒ Object (private)
method to collect all overstepped thresholds indicating significant weather
33 34 35 36 37 38 39 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 33 def collect_active_thresholds @warnings = Hash.new() @warnings[:air_temperature] = collect_thresholds_for(@temperature_threshold) @warnings[:wind_speed] = collect_thresholds_for(@wind_threshold) @warnings[:rain] = collect_thresholds_for(@rain_threshold) nil end |
#collect_thresholds_for(threshold) ⇒ Object (private)
method to collect the overstepped thresholds for the given measurand threshold
42 43 44 45 46 47 48 |
# File 'lib/wrf_forecast/threshold/threshold_handler.rb', line 42 def collect_thresholds_for(threshold) active_thresholds = Array.new() threshold.indicators.each_value { |value| active_thresholds << value if(value.is_active) } return active_thresholds end |