Sha256: 893e9d92acd35ac07c0ac633f7d546fe52671f7e1c5931677eb5891aba64671a
Contents?: true
Size: 624 Bytes
Versions: 1
Compression:
Stored size: 624 Bytes
Contents
require 'geo/coord' require 'airports' class Vfrmap::Location def self.factory(location_string) coordinates = try_coordinates(location_string) return coordinates if coordinates airport = try_airport(location_string) return airport if airport end private def self.try_coordinates(location_string) Geo::Coord.parse(location_string) end def self.try_airport(location_string) case when location_string.length == 3 Airports.find_by_iata_code(location_string.upcase) when location_string.length == 4 Airports.find_by_icao_code(location_string.upcase) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vfrmap-1.1.0 | lib/vfrmap/location.rb |