|
# File rbot/utils.rb, line 189
def initialize(string)
str = nil
@nodata = false
string.each_line {|l|
if str == nil
# grab first line (date)
@date = l.chomp.strip
str = ""
else
if(str == "")
str = l.chomp.strip
else
str += " " + l.chomp.strip
end
end
}
if @date && @date =~ /^(\d+)\/(\d+)\/(\d+) (\d+):(\d+)$/
# 2002/02/26 05:00
@date = Time.gm($1, $2, $3, $4, $5, 0)
else
@date = Time.now
end
@input = str.chomp
@cloud_layers = 0
@cloud_coverage = {
'SKC' => '0',
'CLR' => '0',
'VV' => '8/8',
'FEW' => '1/8 - 2/8',
'SCT' => '3/8 - 4/8',
'BKN' => '5/8 - 7/8',
'OVC' => '8/8'
}
@wind_dir_texts = [
'North',
'North/Northeast',
'Northeast',
'East/Northeast',
'East',
'East/Southeast',
'Southeast',
'South/Southeast',
'South',
'South/Southwest',
'Southwest',
'West/Southwest',
'West',
'West/Northwest',
'Northwest',
'North/Northwest',
'North'
]
@wind_dir_texts_short = [
'N',
'N/NE',
'NE',
'E/NE',
'E',
'E/SE',
'SE',
'S/SE',
'S',
'S/SW',
'SW',
'W/SW',
'W',
'W/NW',
'NW',
'N/NW',
'N'
]
@weather_array = {
'MI' => 'Mild ',
'PR' => 'Partial ',
'BC' => 'Patches ',
'DR' => 'Low Drifting ',
'BL' => 'Blowing ',
'SH' => 'Shower(s) ',
'TS' => 'Thunderstorm ',
'FZ' => 'Freezing',
'DZ' => 'Drizzle ',
'RA' => 'Rain ',
'SN' => 'Snow ',
'SG' => 'Snow Grains ',
'IC' => 'Ice Crystals ',
'PE' => 'Ice Pellets ',
'GR' => 'Hail ',
'GS' => 'Small Hail and/or Snow Pellets ',
'UP' => 'Unknown ',
'BR' => 'Mist ',
'FG' => 'Fog ',
'FU' => 'Smoke ',
'VA' => 'Volcanic Ash ',
'DU' => 'Widespread Dust ',
'SA' => 'Sand ',
'HZ' => 'Haze ',
'PY' => 'Spray',
'PO' => 'Well-Developed Dust/Sand Whirls ',
'SQ' => 'Squalls ',
'FC' => 'Funnel Cloud Tornado Waterspout ',
'SS' => 'Sandstorm/Duststorm '
}
@cloud_condition_array = {
'SKC' => 'clear',
'CLR' => 'clear',
'VV' => 'vertical visibility',
'FEW' => 'a few',
'SCT' => 'scattered',
'BKN' => 'broken',
'OVC' => 'overcast'
}
@strings = {
'mm_inches' => '%s mm (%s inches)',
'precip_a_trace' => 'a trace',
'precip_there_was' => 'There was %s of precipitation ',
'sky_str_format1' => 'There were %s at a height of %s meters (%s feet)',
'sky_str_clear' => 'The sky was clear',
'sky_str_format2' => ', %s at a height of %s meter (%s feet) and %s at a height of %s meters (%s feet)',
'sky_str_format3' => ' and %s at a height of %s meters (%s feet)',
'clouds' => ' clouds',
'clouds_cb' => ' cumulonimbus clouds',
'clouds_tcu' => ' towering cumulus clouds',
'visibility_format' => 'The visibility was %s kilometers (%s miles).',
'wind_str_format1' => 'blowing at a speed of %s meters per second (%s miles per hour)',
'wind_str_format2' => ', with gusts to %s meters per second (%s miles per hour),',
'wind_str_format3' => ' from the %s',
'wind_str_calm' => 'calm',
'precip_last_hour' => 'in the last hour. ',
'precip_last_6_hours' => 'in the last 3 to 6 hours. ',
'precip_last_24_hours' => 'in the last 24 hours. ',
'precip_snow' => 'There is %s mm (%s inches) of snow on the ground. ',
'temp_min_max_6_hours' => 'The maximum and minimum temperatures over the last 6 hours were %s and %s degrees Celsius (%s and %s degrees Fahrenheit).',
'temp_max_6_hours' => 'The maximum temperature over the last 6 hours was %s degrees Celsius (%s degrees Fahrenheit). ',
'temp_min_6_hours' => 'The minimum temperature over the last 6 hours was %s degrees Celsius (%s degrees Fahrenheit). ',
'temp_min_max_24_hours' => 'The maximum and minimum temperatures over the last 24 hours were %s and %s degrees Celsius (%s and %s degrees Fahrenheit). ',
'light' => 'Light ',
'moderate' => 'Moderate ',
'heavy' => 'Heavy ',
'mild' => 'Mild ',
'nearby' => 'Nearby ',
'current_weather' => 'Current weather is %s. ',
'pretty_print_metar' => '%s on %s, the wind was %s at %s. The temperature was %s degrees Celsius (%s degrees Fahrenheit), and the pressure was %s hPa (%s inHg). The relative humidity was %s%%. %s %s %s %s %s'
}
parse
end
|