Class: Geocoder::Result::GeocoderUs

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/geocoder_us.rb

Instance Attribute Summary

Attributes inherited from Base

#cache_hit, #data

Instance Method Summary collapse

Methods inherited from Base

#initialize, #latitude, #longitude, #province, #province_code

Constructor Details

This class inherits a constructor from Geocoder::Result::Base

Instance Method Details

#address(format = :full) ⇒ Object


9
10
11
# File 'lib/geocoder/results/geocoder_us.rb', line 9

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

#cityObject


17
18
19
# File 'lib/geocoder/results/geocoder_us.rb', line 17

def city
  @data[3]
end

#coordinatesObject


5
6
7
# File 'lib/geocoder/results/geocoder_us.rb', line 5

def coordinates
  [@data[0].to_f, @data[1].to_f]
end

#countryObject


31
32
33
# File 'lib/geocoder/results/geocoder_us.rb', line 31

def country
  'United States'
end

#country_codeObject


35
36
37
# File 'lib/geocoder/results/geocoder_us.rb', line 35

def country_code
  'US'
end

#postal_codeObject


27
28
29
# File 'lib/geocoder/results/geocoder_us.rb', line 27

def postal_code
  @data[5]
end

#stateObject Also known as: state_code


21
22
23
# File 'lib/geocoder/results/geocoder_us.rb', line 21

def state
  @data[4]
end

#street_addressObject


13
14
15
# File 'lib/geocoder/results/geocoder_us.rb', line 13

def street_address
  @data[2]
end