lib/vfrmap/location.rb in vfrmap-1.0.1 vs lib/vfrmap/location.rb in vfrmap-1.1.0
- old
+ new
@@ -15,8 +15,13 @@
def self.try_coordinates(location_string)
Geo::Coord.parse(location_string)
end
def self.try_airport(location_string)
- Airports.find_by_iata_code(location_string.upcase)
+ 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