Class: WrfForecast::Text::PressureText
- Inherits:
-
MeasurandText
- Object
- MeasurandText
- WrfForecast::Text::PressureText
- Defined in:
- lib/wrf_forecast/forecast/pressure_text.rb
Overview
This class generates the forecast text for the pressure data of the forecast warnings: no warnings at the moment
Instance Attribute Summary collapse
-
#pressure_mean ⇒ Float
readonly
private
The mean value of the pressure dataset.
Attributes inherited from MeasurandText
#extreme_values, #text, #thresholds, #warnings
Instance Method Summary collapse
-
#create_attribute_text ⇒ String
private
method to generate the text about the day.
-
#create_pressure_text ⇒ String
private
method to generate the text with air pressure values.
-
#generate_forecast_text ⇒ Object
private
method to generate the forecast text for the air pressure.
-
#generate_warning_text ⇒ String
private
method to generate the warning text for the measurand.
-
#initialize(extreme_values, pressure_data, thresholds) ⇒ PressureText
constructor
initialization.
Methods inherited from MeasurandText
Constructor Details
#initialize(extreme_values, pressure_data, thresholds) ⇒ PressureText
initialization
13 14 15 16 |
# File 'lib/wrf_forecast/forecast/pressure_text.rb', line 13 def initialize(extreme_values, pressure_data, thresholds) @pressure_mean = (pressure_data.sum(0.0) / (pressure_data.size * 100)).round(1) super(extreme_values, thresholds) end |
Instance Attribute Details
#pressure_mean ⇒ Float (readonly, private)
Returns the mean value of the pressure dataset.
21 22 23 |
# File 'lib/wrf_forecast/forecast/pressure_text.rb', line 21 def pressure_mean @pressure_mean end |
Instance Method Details
#create_attribute_text ⇒ String (private)
method to generate the text about the day
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/wrf_forecast/forecast/pressure_text.rb', line 41 def create_attribute_text attribute = I18n.t("forecast_text.pressure.level_normal") if (is_threshold_active?(:very_low_pressure)) attribute = I18n.t("forecast_text.pressure.level_very_low") elsif (is_threshold_active?(:low_pressure)) attribute = I18n.t("forecast_text.pressure.level_low") elsif (is_threshold_active?(:very_high_pressure)) attribute = I18n.t("forecast_text.pressure.level_very_high") elsif (is_threshold_active?(:high_pressure)) attribute = I18n.t("forecast_text.pressure.level_high") end attribute end |
#create_pressure_text ⇒ String (private)
method to generate the text with air pressure values
57 58 59 60 61 62 63 64 |
# File 'lib/wrf_forecast/forecast/pressure_text.rb', line 57 def create_pressure_text text = I18n.t("forecast_text.pressure.text_maximum") text.concat((@extreme_values.maximum / 100).ceil.to_s) text.concat(I18n.t("forecast_text.pressure.text_minimum")) text.concat((@extreme_values.minimum / 100).floor.to_s) text.concat(I18n.t("forecast_text.pressure.text_finish")) text end |
#generate_forecast_text ⇒ Object (private)
method to generate the forecast text for the air pressure
24 25 26 27 28 29 30 |
# File 'lib/wrf_forecast/forecast/pressure_text.rb', line 24 def generate_forecast_text @text = I18n.t("forecast_text.pressure.text_start") @text.concat(create_attribute_text).concat(I18n.t("forecast_text.pressure.text_with")) @text.concat(@pressure_mean.to_s).concat(I18n.t("forecast_text.pressure.text_continue")) @text.concat(create_pressure_text) nil end |
#generate_warning_text ⇒ String (private)
method to generate the warning text for the measurand
34 35 36 37 |
# File 'lib/wrf_forecast/forecast/pressure_text.rb', line 34 def generate_warning_text # no warning criterias @warnings end |