Sha256: b8763fe91c2c7f08ef72ba0279a1d881a941bf8831edd278c51eee7d5790cbaa

Contents?: true

Size: 1.2 KB

Versions: 23

Compression:

Stored size: 1.2 KB

Contents

require 'geocoder/results/base'

module Geocoder::Result
  class GeoportailLu < Base

    def coordinates
      geomlonlat['coordinates'].reverse if geolocalized?
    end

    def address
      full_address
    end

    def city
      try_to_extract 'locality', detailled_address
    end

    def state
      'Luxembourg'
    end

    def state_code
      'LU'
    end

    def postal_code
      try_to_extract 'zip', detailled_address
    end

    def street_address
      [street_number, street].compact.join(' ')
    end

    def street_number
      try_to_extract 'postnumber', detailled_address
    end

    def street
      try_to_extract 'street', detailled_address
    end

    def full_address
      data['address']
    end

    def geomlonlat
      data['geomlonlat']
    end

    def detailled_address
      data['AddressDetails']
    end

    alias_method :country, :state
    alias_method :province, :state
    alias_method :country_code, :state_code
    alias_method :province_code, :state_code

    private

    def geolocalized?
      !!try_to_extract('coordinates', geomlonlat)
    end

    def try_to_extract(key, hash)
      if hash.is_a?(Hash) and hash.include?(key)
        hash[key]
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
geocoder-1.8.3 lib/geocoder/results/geoportail_lu.rb
geocoder-1.8.2 lib/geocoder/results/geoportail_lu.rb
geocoder-1.8.1 lib/geocoder/results/geoportail_lu.rb
geocoder-1.8.0 lib/geocoder/results/geoportail_lu.rb
geocoder-1.7.5 lib/geocoder/results/geoportail_lu.rb
geocoder-1.7.4 lib/geocoder/results/geoportail_lu.rb
geocoder-1.7.3 lib/geocoder/results/geoportail_lu.rb
geocoder-1.7.2 lib/geocoder/results/geoportail_lu.rb
geocoder-1.7.1 lib/geocoder/results/geoportail_lu.rb
geocoder-1.7.0 lib/geocoder/results/geoportail_lu.rb
geocoder-1.6.7 lib/geocoder/results/geoportail_lu.rb
geocoder-1.6.6 lib/geocoder/results/geoportail_lu.rb
geocoder-1.6.5 lib/geocoder/results/geoportail_lu.rb
geocoder-1.6.4 lib/geocoder/results/geoportail_lu.rb
geocoder-1.6.3 lib/geocoder/results/geoportail_lu.rb
geocoder-1.6.2 lib/geocoder/results/geoportail_lu.rb
geocoder-1.6.1 lib/geocoder/results/geoportail_lu.rb
geocoder-1.6.0 lib/geocoder/results/geoportail_lu.rb
geocoder-1.5.2 lib/geocoder/results/geoportail_lu.rb
really-broken-geocoder-2.0.0 lib/geocoder/results/geoportail_lu.rb