Class: Geocoder::Result::SmartyStreets

Inherits:
Base
  • Object
show all
Defined in:
lib/geocoder/results/smarty_streets.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

#addressObject



11
12
13
14
15
16
17
# File 'lib/geocoder/results/smarty_streets.rb', line 11

def address
  [
    delivery_line_1,
    delivery_line_2,
    last_line
  ].select{ |i| i.to_s != "" }.join(" ")
end

#cityObject



47
48
49
50
51
# File 'lib/geocoder/results/smarty_streets.rb', line 47

def city
  zipcode_endpoint? ?
    city_states.first['city'] :
    components['city_name']
end

#coordinatesObject



5
6
7
8
9
# File 'lib/geocoder/results/smarty_streets.rb', line 5

def coordinates
  %w(latitude longitude).map do |i|
    zipcode_endpoint? ? zipcodes.first[i] : [i]
  end
end

#countryObject



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

def country
  # SmartyStreets returns results for USA only
  "United States"
end

#country_codeObject



36
37
38
39
# File 'lib/geocoder/results/smarty_streets.rb', line 36

def country_code
  # SmartyStreets returns results for USA only
  "US"
end

#fipsObject



65
66
67
68
69
# File 'lib/geocoder/results/smarty_streets.rb', line 65

def fips
  zipcode_endpoint? ?
    zipcodes.first['county_fips'] :
    ['county_fips']
end

#stateObject



19
20
21
22
23
# File 'lib/geocoder/results/smarty_streets.rb', line 19

def state
  zipcode_endpoint? ?
    city_states.first['state'] :
    components['state_abbreviation']
end

#state_codeObject



25
26
27
28
29
# File 'lib/geocoder/results/smarty_streets.rb', line 25

def state_code
  zipcode_endpoint? ?
    city_states.first['state_abbreviation'] :
    components['state_abbreviation']
end

#streetObject

Extra methods not in base.rb ————————



43
44
45
# File 'lib/geocoder/results/smarty_streets.rb', line 43

def street
  components['street_name']
end

#zip4Object Also known as: postal_code_extended



60
61
62
# File 'lib/geocoder/results/smarty_streets.rb', line 60

def zip4
  components['plus4_code']
end

#zipcodeObject Also known as: postal_code



53
54
55
56
57
# File 'lib/geocoder/results/smarty_streets.rb', line 53

def zipcode
  zipcode_endpoint? ?
    zipcodes.first['zipcode'] :
    components['zipcode']
end

#zipcode_endpoint?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/geocoder/results/smarty_streets.rb', line 71

def zipcode_endpoint?
  zipcodes.any?
end