Sha256: 883c4c9810f942168a0f7c61dd3eb5e384e9a43fd9a66aceb450494bf25e5eb2

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 Bytes

Contents

require 'sora_geocoding/results/base'

module SoraGeocoding
  module Results
    #
    # get the latitude and longitude of the Geocoding API
    #
    class Geocoding < Base
      def coordinates
        check_data_for_errors!

        common = '/result/coordinate'
        lat = @data.elements["#{common}/lat"].get_text
        lon = @data.elements["#{common}/lng"].get_text
        { lat: lat, lon: lon }
      end

      def check_data_for_errors!
        error = @data.elements['/result/error']
        return unless error

        code = error.get_text.to_s
        SoraGeocoding.log(:error, "Geocoding API error: #{code} Zero Results")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sora_geocoding-0.2.2 lib/sora_geocoding/results/geocoding.rb
sora_geocoding-0.2.0 lib/sora_geocoding/results/geocoding.rb
sora_geocoding-0.1.0 lib/sora_geocoding/results/geocoding.rb