Class: WrfForecast::Text::TemperatureText

Inherits:
MeasurandText show all
Defined in:
lib/wrf_forecast/forecast/temperature_text.rb

Overview

This class generates the forecast text for the temperature data of the forecast warnings: the hot day contains the summer day and can have a tropical night or frost day but exclude the ice day the ice day contains the frost day, both exclude tropical night

Instance Attribute Summary

Attributes inherited from MeasurandText

#extreme_values, #text, #thresholds, #warnings

Instance Method Summary collapse

Methods inherited from MeasurandText

#initialize, #is_threshold_active?

Constructor Details

This class inherits a constructor from WrfForecast::Text::MeasurandText

Instance Method Details

#create_temperature_textObject (private)

method to generate the text with temperature values



56
57
58
59
60
61
62
63
# File 'lib/wrf_forecast/forecast/temperature_text.rb', line 56

def create_temperature_text
  text = I18n.t("forecast_text.temperature.text_maximum")
  text.concat((@extreme_values.maximum - 273.15).ceil.to_s)
  text.concat(I18n.t("forecast_text.temperature.text_minimum"))
  text.concat((@extreme_values.minimum - 273.15).floor.to_s)
  text.concat(I18n.t("forecast_text.temperature.text_finish"))
  return text
end

#create_warmth_textObject (private)

method to generate the text about the day



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/wrf_forecast/forecast/temperature_text.rb', line 32

def create_warmth_text
  warmth = I18n.t("forecast_text.temperature.warmth_normal")
  if (is_threshold_active?(:ice_day))
    warmth = I18n.t("forecast_text.temperature.warmth_very_frosty")
  elsif (@thresholds[:frost_day].is_active)
    warmth = I18n.t("forecast_text.temperature.warmth_cold")
  end

  if (is_threshold_active?(:hot_day))
    warmth = I18n.t("forecast_text.temperature.warmth_hot")
  elsif (is_threshold_active?(:summer_day))
    warmth = I18n.t("forecast_text.temperature.warmth_summer")
  end

  warmth.concat(I18n.t("forecast_text.temperature.text_day"))
  if (@thresholds[:tropical_night].is_active)
    warmth.concat(I18n.t("forecast_text.temperature.warmth_tropical"))
    @warnings.concat("\n") if (!@warnings.empty?)
    @warnings.concat(@thresholds[:tropical_night].warning_text)
  end
  return warmth
end

#generate_forecast_textObject (private)

method to generate the forecast text for the temperature



15
16
17
18
19
20
# File 'lib/wrf_forecast/forecast/temperature_text.rb', line 15

def generate_forecast_text
  @text = I18n.t("forecast_text.temperature.text_start")
  @text.concat(create_warmth_text).concat(".")
  @text.concat(create_temperature_text)
  nil
end

#generate_warning_textObject (private)

method to generate the warning text for the measurand



23
24
25
26
27
28
29
# File 'lib/wrf_forecast/forecast/temperature_text.rb', line 23

def generate_warning_text
  if (@thresholds[:frost_day].is_active && !@thresholds[:ice_day].is_active)
    @warnings.concat"\n" if (!@warnings.empty?)
    @warnings.concat(@thresholds[:frost_day].warning_text)
  end  
  @warnings
end