Class: WrfForecast::Text::MeasurandText
- Inherits:
-
Object
- Object
- WrfForecast::Text::MeasurandText
- Defined in:
- lib/wrf_forecast/forecast/measurand_text.rb
Overview
This abstract class serves as the prarent class to measurand specific forecast texts. It contains the resulting forecast text for the measurand based on the input data and the warnings specified in the corresponding threshold class.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#extreme_values ⇒ ExtremeValues
readonly
private
The measurand extreme values.
-
#text ⇒ String
readonly
The forecast text for the measurand.
-
#thresholds ⇒ TemperatureThreshold
readonly
private
The measurand thresholds.
-
#warnings ⇒ String
readonly
The warning text for the measurand.
Instance Method Summary collapse
-
#generate_forecast_text ⇒ Object
private
abstract method to generate the forecast text for the measurand.
-
#generate_warning_text ⇒ Object
private
abstract method to generate the warning text for the measurand.
-
#initialize(extreme_values, thresholds) ⇒ MeasurandText
constructor
initialization.
-
#is_threshold_active?(indicator) ⇒ Boolean
private
method to determine if the threshold for the given indicator is active.
Constructor Details
#initialize(extreme_values, thresholds) ⇒ MeasurandText
initialization
19 20 21 22 23 24 25 26 |
# File 'lib/wrf_forecast/forecast/measurand_text.rb', line 19 def initialize(extreme_values, thresholds) @extreme_values = extreme_values @thresholds = thresholds @text = "" @warnings = "" generate_forecast_text generate_warning_text end |
Instance Attribute Details
#extreme_values ⇒ ExtremeValues (readonly, private)
Returns the measurand extreme values.
31 32 33 |
# File 'lib/wrf_forecast/forecast/measurand_text.rb', line 31 def extreme_values @extreme_values end |
#text ⇒ String (readonly)
Returns the forecast text for the measurand.
12 13 14 |
# File 'lib/wrf_forecast/forecast/measurand_text.rb', line 12 def text @text end |
#thresholds ⇒ TemperatureThreshold (readonly, private)
Returns the measurand thresholds.
33 34 35 |
# File 'lib/wrf_forecast/forecast/measurand_text.rb', line 33 def thresholds @thresholds end |
#warnings ⇒ String (readonly)
Returns the warning text for the measurand.
14 15 16 |
# File 'lib/wrf_forecast/forecast/measurand_text.rb', line 14 def warnings @warnings end |
Instance Method Details
#generate_forecast_text ⇒ Object (private)
abstract method to generate the forecast text for the measurand
47 48 49 50 |
# File 'lib/wrf_forecast/forecast/measurand_text.rb', line 47 def generate_forecast_text fail NotImplementedError, " Error: the subclass #{self.class} needs " \ "to implement the method: generate_forecast_text from its base class".red end |
#generate_warning_text ⇒ Object (private)
abstract method to generate the warning text for the measurand
54 55 56 57 |
# File 'lib/wrf_forecast/forecast/measurand_text.rb', line 54 def generate_warning_text fail NotImplementedError, " Error: the subclass #{self.class} needs " \ "to implement the method: generate_warning_text from its base class".red end |
#is_threshold_active?(indicator) ⇒ Boolean (private)
method to determine if the threshold for the given indicator is active
38 39 40 41 42 43 |
# File 'lib/wrf_forecast/forecast/measurand_text.rb', line 38 def is_threshold_active?(indicator) if (@thresholds[indicator].is_active) @warnings = @thresholds[indicator].warning_text end @thresholds[indicator].is_active end |