Sha256: 288c33b65f16ffc674c963cd1b8059c5d877b9a4850072b2778704a24624618c
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module Barometer # # Format: ICAO (International Civil Aviation Organization) # # eg. KLAX (Los Angeles Airport) # # This class is used to determine if a query is a # :icao and what the country_code is. # class Query::Format::Icao < Query::Format @@codes_file = File.expand_path( File.join(File.dirname(__FILE__), '..', 'translations', 'icao_country_codes.yml')) @@codes = nil def self.format; :icao; end # 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=nil) 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
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
attack-barometer-0.5.0 | lib/barometer/formats/icao.rb |
barometer-0.5.0 | lib/barometer/formats/icao.rb |