Sha256: a3e51f709f9950e79c68a7530bbb0eee760c5eb6c13c9e23d4378d9eeff1091d

Contents?: true

Size: 972 Bytes

Versions: 18

Compression:

Stored size: 972 Bytes

Contents

require 'geocoder/results/base'

module Geocoder::Result
  class Osmnames < Base
    def address
      @data['display_name']
    end

    def coordinates
      [@data['lat'].to_f, @data['lon'].to_f]
    end

    def viewport
      west, south, east, north = @data['boundingbox'].map(&:to_f)
      [south, west, north, east]
    end

    def state
      @data['state']
    end
    alias_method :state_code, :state

    def place_class
      @data['class']
    end

    def place_type
      @data['type']
    end

    def postal_code
      ''
    end

    def country_code
      @data['country_code']
    end

    def country
      @data['country']
    end

    def self.response_attributes
      %w[house_number street city name osm_id osm_type boundingbox place_rank
      importance county rank name_suffix]
    end

    response_attributes.each do |a|
      unless method_defined?(a)
        define_method a do
          @data[a]
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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