Sha256: 85b74582743bcfcf3ad8c413af69496c85b7d31cb24daebb508753c99ddbca0b

Contents?: true

Size: 1.08 KB

Versions: 46

Compression:

Stored size: 1.08 KB

Contents

module Geocoder
  module Result
    class Base

      # data (hash) fetched from geocoding service
      attr_accessor :data

      # true if result came from cache, false if from request to geocoding
      # service; nil if cache is not configured
      attr_accessor :cache_hit

      ##
      # Takes a hash of data from a parsed geocoding service response.
      #
      def initialize(data)
        @data = data
        @cache_hit = nil
      end

      ##
      # A string in the given format.
      #
      def address(format = :full)
        fail
      end

      ##
      # A two-element array: [lat, lon].
      #
      def coordinates
        [@data['latitude'].to_f, @data['longitude'].to_f]
      end

      def latitude
        coordinates[0]
      end

      def longitude
        coordinates[1]
      end

      def state
        fail
      end

      def province
        state
      end

      def state_code
        fail
      end

      def province_code
        state_code
      end

      def country
        fail
      end

      def country_code
        fail
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 6 rubygems

Version Path
geocoder-1.4.9 lib/geocoder/results/base.rb
geocoder-1.4.8 lib/geocoder/results/base.rb
geocoder-1.4.7 lib/geocoder/results/base.rb
geocoder-1.4.6 lib/geocoder/results/base.rb
geocoder-1.4.5 lib/geocoder/results/base.rb
geocoder-1.4.4 lib/geocoder/results/base.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/geocoder-1.4.3/lib/geocoder/results/base.rb
geocoder-1.4.3 lib/geocoder/results/base.rb
geocoder-1.4.2 lib/geocoder/results/base.rb
geocoder-1.4.1 lib/geocoder/results/base.rb
geocoder-1.4.0 lib/geocoder/results/base.rb
geocoder-1.3.7 lib/geocoder/results/base.rb
geocoder-1.3.6 lib/geocoder/results/base.rb
geocoder-1.3.5 lib/geocoder/results/base.rb
broken-geocoder-1.3.6 lib/geocoder/results/base.rb
broken-geocoder-1.3.5 lib/geocoder/results/base.rb
broken-geocoder-1.3.4 lib/geocoder/results/base.rb
geocoder-1.3.4 lib/geocoder/results/base.rb
geocoder-1.3.3 lib/geocoder/results/base.rb
geocoder-1.3.2 lib/geocoder/results/base.rb