Google

# File rbot/utils.rb, line 634
      def pretty_print
       if @nodata
         return "The weather stored for #{@decoded['station']} consists of the string 'NIL' :("
       end

       ["temp_c", "altimeter_hpa"].each {|key|
         if !@decoded.has_key?(key)
           return "The weather stored for #{@decoded['station']} could not be parsed (#{@input})"
         end
       }
       
       mins_old = ((Time.now - @date.to_i).to_f/60).round
       if (mins_old <= 60)
         weather_age = mins_old.to_s + " minutes ago,"
       elsif (mins_old <= 60 * 25)
         weather_age = (mins_old / 60).to_s + " hours, "
         weather_age += (mins_old % 60).to_s + " minutes ago,"
       else
         # return "The weather stored for #{@decoded['station']} is hideously out of date :( (Last update #{@date})"
         weather_age = "The weather stored for #{@decoded['station']} is hideously out of date :( here it is anyway:"
       end
        
       if(@decoded.has_key?("cloud_layer1_altitude_ft"))
         sky_str = sprintf(@strings['sky_str_format1'],
                           @decoded["cloud_layer1_condition"],
                           @decoded["cloud_layer1_altitude_m"],
                           @decoded["cloud_layer1_altitude_ft"])
       else
         sky_str = @strings['sky_str_clear']
       end

       if(@decoded.has_key?("cloud_layer2_altitude_ft"))
         if(@decoded.has_key?("cloud_layer3_altitude_ft"))
           sky_str += sprintf(@strings['sky_str_format2'],
                              @decoded["cloud_layer2_condition"],
                              @decoded["cloud_layer2_altitude_m"],
                              @decoded["cloud_layer2_altitude_ft"],
                              @decoded["cloud_layer3_condition"],
                              @decoded["cloud_layer3_altitude_m"],
                              @decoded["cloud_layer3_altitude_ft"])
         else
           sky_str += sprintf(@strings['sky_str_format3'],
                              @decoded["cloud_layer2_condition"],
                              @decoded["cloud_layer2_altitude_m"],
                              @decoded["cloud_layer2_altitude_ft"])
         end
       end
       sky_str += "."

       if(@decoded.has_key?("visibility_miles"))
         visibility = sprintf(@strings['visibility_format'],
                              @decoded["visibility_km"],
                              @decoded["visibility_miles"])
       else
         visibility = ""
       end

       if (@decoded.has_key?("wind_meters_per_second") && @decoded["wind_meters_per_second"].to_i > 0)
         wind_str = sprintf(@strings['wind_str_format1'],
                            @decoded["wind_meters_per_second"],
                            @decoded["wind_miles_per_hour"])
         if (@decoded.has_key?("wind_gust_meters_per_second") && @decoded["wind_gust_meters_per_second"].to_i > 0)
           wind_str += sprintf(@strings['wind_str_format2'],
                               @decoded["wind_gust_meters_per_second"],
                               @decoded["wind_gust_miles_per_hour"])
         end
         wind_str += sprintf(@strings['wind_str_format3'],
                             @decoded["wind_dir_text"])
       else
         wind_str = @strings['wind_str_calm']
       end

       prec_str = ""
       if (@decoded.has_key?("precip_in"))
         prec_str += pretty_print_precip(@decoded["precip_mm"], @decoded["precip_in"]) + @strings['precip_last_hour']
       end
       if (@decoded.has_key?("precip_6h_in"))
         prec_str += pretty_print_precip(@decoded["precip_6h_mm"], @decoded["precip_6h_in"]) + @strings['precip_last_6_hours']
       end
       if (@decoded.has_key?("precip_24h_in"))
         prec_str += pretty_print_precip(@decoded["precip_24h_mm"], @decoded["precip_24h_in"]) + @strings['precip_last_24_hours']
       end
       if (@decoded.has_key?("snow_in"))
         prec_str += sprintf(@strings['precip_snow'], @decoded["snow_mm"], @decoded["snow_in"])
       end

       temp_str = ""
       if (@decoded.has_key?("temp_max6h_c") && @decoded.has_key?("temp_min6h_c"))
         temp_str += sprintf(@strings['temp_min_max_6_hours'],
                             @decoded["temp_max6h_c"],
                             @decoded["temp_min6h_c"],
                             @decoded["temp_max6h_f"],
                             @decoded["temp_min6h_f"])
       else
         if (@decoded.has_key?("temp_max6h_c"))
           temp_str += sprintf(@strings['temp_max_6_hours'],
                               @decoded["temp_max6h_c"],
                               @decoded["temp_max6h_f"])
         end
         if (@decoded.has_key?("temp_min6h_c"))
           temp_str += sprintf(@strings['temp_max_6_hours'],
                               @decoded["temp_min6h_c"],
                               @decoded["temp_min6h_f"])
         end
       end
       if (@decoded.has_key?("temp_max24h_c"))
         temp_str += sprintf(@strings['temp_min_max_24_hours'],
                             @decoded["temp_max24h_c"],
                             @decoded["temp_min24h_c"],
                             @decoded["temp_max24h_f"],
                             @decoded["temp_min24h_f"])
       end

       if (@decoded.has_key?("weather"))
         weather_str = sprintf(@strings['current_weather'], @decoded["weather"])
       else
         weather_str = ''
       end

       return sprintf(@strings['pretty_print_metar'],
                      weather_age,
                      @date,
                      wind_str, @decoded["station"], @decoded["temp_c"],
                      @decoded["temp_f"], @decoded["altimeter_hpa"],
                      @decoded["altimeter_inhg"],
                      @decoded["rel_humidity"], sky_str,
                      visibility, weather_str, prec_str, temp_str).strip
      end