Class: WrfForecast::JsonConverter::TextForecastJsonConverter
- Inherits:
 - 
      ForecastStationJsonConverter
      
        
- Object
 - WrfLibrary::JsonConverter::BaseStationJsonConverter
 - ForecastStationJsonConverter
 - WrfForecast::JsonConverter::TextForecastJsonConverter
 
 
- Defined in:
 - lib/wrf_forecast/json_converter/text_forecast_converter.rb
 
Overview
Child class to generate valid json output for the result data of a given wrf meteogram result already stored in a data repository
Instance Attribute Summary
Attributes inherited from ForecastStationJsonConverter
Instance Method Summary collapse
- 
  
    
      #generate_rain_values  ⇒ Object 
    
    
  
  
  
  
  private
  
  
  
  
    
method to create the output hash for the precipitation values.
 - 
  
    
      #generate_temperature_values  ⇒ Object 
    
    
  
  
  
  
  private
  
  
  
  
    
method to create the output hash for the temperature values.
 - 
  
    
      #generate_wind_values  ⇒ Object 
    
    
  
  
  
  
  private
  
  
  
  
    
method to create the output hash for the wind values.
 
Methods inherited from ForecastStationJsonConverter
#add_additions, #convert_suntime, #generate_data_values, #generate_warnings, #initialize
Constructor Details
This class inherits a constructor from WrfForecast::JsonConverter::ForecastStationJsonConverter
Instance Method Details
#generate_rain_values ⇒ Object (private)
method to create the output hash for the precipitation values
      30 31 32 33 34 35 36 37 38 39 40 41  | 
    
      # File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 30 def generate_rain_values extreme_values = @forecast.extreme_values[:rain] values = Hash.new() values[:minimum] = extreme_values.minimum.round(3) values[:maximum] = extreme_values.maximum.round(3) rain_sum = 0 @forecast.hourly_rain.each { |value| rain_sum += value } values[:sum] = rain_sum.round(3) return values end  | 
  
#generate_temperature_values ⇒ Object (private)
method to create the output hash for the temperature values
      12 13 14 15 16  | 
    
      # File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 12 def generate_temperature_values extreme_values = @forecast.extreme_values[:air_temperature] return { :minimum => extreme_values.minimum.round(3), :maximum => extreme_values.maximum.round(3) } end  | 
  
#generate_wind_values ⇒ Object (private)
method to create the output hash for the wind values
      19 20 21 22 23 24 25 26 27  | 
    
      # File 'lib/wrf_forecast/json_converter/text_forecast_converter.rb', line 19 def generate_wind_values extreme_values = @forecast.extreme_values[:wind_speed] prevalent_direction = WrfForecast::Directions.new().get_direction_string(@forecast.prevalent_direction) values = Hash.new() values[:minimum] = extreme_values.minimum.round(3) values[:maximum] = extreme_values.maximum.round(3) values[:prevalent_direction] = prevalent_direction return values end  |