Class: WrfForecast::Text::ApparentTemperatureText

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

Overview

This class generates the forecast text for the apparent temperature data of the forecast

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_textString (private)

method to generate the text with temperature values

Returns:

  • (String)

    the substring containing the temperature values and text conclusion



38
39
40
41
42
43
44
45
# File 'lib/wrf_forecast/forecast/apparent_temperature_text.rb', line 38

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

#create_warmth_textString (private)

method to generate the text about the day

Returns:

  • (String)

    the substring containing the temperature category



26
27
28
29
30
31
32
33
34
# File 'lib/wrf_forecast/forecast/apparent_temperature_text.rb', line 26

def create_warmth_text
  warmth = I18n.t("forecast_text.apparent_temperature.feeling_normal")
  if (is_threshold_active?(:extreme_heat_day))
    warmth = I18n.t("forecast_text.apparent_temperature.feeling_extreme_heat")
  elsif (is_threshold_active?(:strong_heat_day))
    warmth = I18n.t("forecast_text.apparent_temperature.feeling_strong_heat")
  end
  warmth
end

#generate_forecast_textObject (private)

method to generate the forecast text for the apparent temperature



12
13
14
15
16
17
# File 'lib/wrf_forecast/forecast/apparent_temperature_text.rb', line 12

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

#generate_warning_textObject (private)

method to generate the warning text for the measurand



20
21
22
# File 'lib/wrf_forecast/forecast/apparent_temperature_text.rb', line 20

def generate_warning_text 
  @warnings
end