Class: WrfForecast::Text::PressureText

Inherits:
MeasurandText show all
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

Attributes inherited from MeasurandText

#extreme_values, #text, #thresholds, #warnings

Instance Method Summary collapse

Methods inherited from MeasurandText

#is_threshold_active?

Constructor Details

#initialize(extreme_values, pressure_data, thresholds) ⇒ PressureText

initialization

Parameters:

  • extreme_values (ExtremeValues)

    the pressure extreme values

  • pressure_data (Array)

    the pressure data

  • thresholds (WindThreshold)

    the pressure threshold



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_meanFloat (readonly, private)

Returns the mean value of the pressure dataset.

Returns:

  • (Float)

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

method to generate the text about the day

Returns:

  • (String)

    the substring containing the pressure category



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

method to generate the text with air pressure values

Returns:

  • (String)

    the substring containing the pressure values and text conclusion



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

method to generate the warning text for the measurand

Returns:

  • (String)

    the warning text



34
35
36
37
# File 'lib/wrf_forecast/forecast/pressure_text.rb', line 34

def generate_warning_text
  # no warning criterias
  @warnings
end