class Vfrmap::Location
Public Class Methods
factory(location_string)
click to toggle source
# File lib/vfrmap/location.rb, line 5 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 Class Methods
try_airport(location_string)
click to toggle source
# File lib/vfrmap/location.rb, line 19 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
try_coordinates(location_string)
click to toggle source
# File lib/vfrmap/location.rb, line 15 def self.try_coordinates(location_string) Geo::Coord.parse(location_string) end