Sha256: 26b71de74b1c7aedf72248d8bf8da802fa7cbe6e04ec5fa4231d0a4960682f76

Contents?: true

Size: 474 Bytes

Versions: 2

Compression:

Stored size: 474 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)
    Airports.find_by_iata_code(location_string.upcase)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vfrmap-1.0.1 lib/vfrmap/location.rb
vfrmap-1.0.0 lib/vfrmap/location.rb