lib/barometer/formats/weather_id.rb in barometer-0.6.7 vs lib/barometer/formats/weather_id.rb in barometer-0.7.0
- old
+ new
@@ -8,14 +8,10 @@
# :weather_id, how to convert to and from :weather_id
# and what the country_code is.
#
class Query::Format::WeatherID < Query::Format
- @@fixes_file = File.expand_path(
- File.join(File.dirname(__FILE__), '..', 'translations', 'weather_country_codes.yml'))
- @@fixes = nil
-
def self.format; :weather_id; end
def self.regex; /(^[A-Za-z]{4}[0-9]{4}$)/; end
def self.convertable_formats
[:short_zipcode, :zipcode, :coordinates, :icao, :geocode]
end
@@ -88,20 +84,9 @@
def self._parse_geocode(text)
return nil unless text
output = [text["city"], text["region"], _fix_country(text["country"])]
output.delete("")
output.compact.join(', ')
- end
-
- # fix the country code
- #
- # weather.com uses non-standard two letter country codes that
- # hinder the ability to determine the country or fetch geo_data.
- # correct these "mistakes"
- #
- def self._fix_country(country_code)
- @@fixes ||= YAML.load_file(@@fixes_file)
- @@fixes[country_code.upcase.to_s] || country_code
end
end
end
\ No newline at end of file