Sha256: fd81a781397ea82b8c7fee1231208db094250ae0199e7ca1d2e721e0af5534af
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
module Barometer module Query module Format # # ICAO (International Civil Aviation Organization) # eg. KLAX (Los Angeles Airport) # class Icao < Base @@codes_file = File.expand_path( File.join(File.dirname(__FILE__), 'translations', 'icao_country_codes.yml')) @@codes = nil # call any 3-4 letter query, :icao ... obviously this will have a lot # of false positives. So far this isn't an issue as all weather services # that take :icao (which is just one, :wunderground) also take what # this would have been if it was not called :icao. # def self.regex; /^[A-Za-z]{3,4}$/; end # in some cases the first letter can designate the country # def self.country_code(query) return unless query && query.is_a?(String) $:.unshift(File.dirname(__FILE__)) @@codes ||= YAML.load_file(@@codes_file) return unless @@codes && @@codes['one_letter'] && @@codes['two_letter'] @@codes['one_letter'][query[0..0].upcase.to_s] || @@codes['two_letter'][query[0..1].upcase.to_s] || nil end end end end end Barometer::Query::Format.register(:icao, Barometer::Query::Format::Icao)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
barometer-0.9.1 | lib/barometer/query/formats/icao.rb |
barometer-0.9.0 | lib/barometer/query/formats/icao.rb |