Sha256: d5ce1803516142ef60164a5a04ae47886048d59ddd58e59ee218b95c8cb9b454

Contents?: true

Size: 583 Bytes

Versions: 2

Compression:

Stored size: 583 Bytes

Contents

require 'geocoder2/results/base'

module Geocoder2::Result
  class GeocoderUs < Base
    def coordinates
      [@data[0].to_f, @data[1].to_f]
    end

    def address(format = :full)
      "#{street_address}, #{city}, #{state} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
    end

    def street_address
      @data[2]
    end

    def city
      @data[3]
    end

    def state
      @data[4]
    end

    alias_method :state_code, :state

    def postal_code
      @data[5]
    end

    def country
      'United States'
    end

    def country_code
      'US'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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