Sha256: be436d521ff39f10dd4601dc47e53fa058060abdf86af22496da672dc02cfc12

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

require 'geocoder2/results/base'

module Geocoder2::Result
  class Bing < Base

    def address(format = :full)
      @data['address']['formattedAddress']
    end

    def city
      @data['address']['locality']
    end

    def state_code
      @data['address']['adminDistrict']
    end

    alias_method :state, :state_code

    def country
      @data['address']['countryRegion']
    end

    alias_method :country_code, :country

    def postal_code
      @data['address']['postalCode']
    end

    def coordinates
      @data['point']['coordinates']
    end

    def address_data
      @data['address']
    end

    def self.response_attributes
      %w[bbox name confidence entityType]
    end

    response_attributes.each do |a|
      define_method a do
        @data[a]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geocoder2-0.1.1 lib/geocoder2/results/bing.rb
geocoder2-0.1.0 lib/geocoder2/results/bing.rb