Class: Geocodio::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/geocodio/address.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload = {}) ⇒ Address

Returns a new instance of Address.


26
27
28
29
30
31
32
33
# File 'lib/geocodio/address.rb', line 26

def initialize(payload = {})
  set_attributes(payload['address_components']) if payload['address_components']
  set_coordinates(payload['location'])          if payload['location']
  set_additional_fields(payload['fields'])      if payload['fields']

  @accuracy          = payload['accuracy']
  @formatted_address = payload['formatted_address']
end

Instance Attribute Details

#accuracyFloat (readonly)

How accurate geocod.io deemed this result to be given the original query.

Returns:

  • (Float)

    a number between 0 and 1


24
25
26
# File 'lib/geocodio/address.rb', line 24

def accuracy
  @accuracy
end

#cityObject (readonly)

Returns the value of attribute city


8
9
10
# File 'lib/geocodio/address.rb', line 8

def city
  @city
end

#congressional_districtsObject (readonly)

Returns the value of attribute congressional_districts


15
16
17
# File 'lib/geocodio/address.rb', line 15

def congressional_districts
  @congressional_districts
end

#countyObject (readonly)

Returns the value of attribute county


8
9
10
# File 'lib/geocodio/address.rb', line 8

def county
  @county
end

#elementary_school_districtObject (readonly)

Returns the value of attribute elementary_school_district


15
16
17
# File 'lib/geocodio/address.rb', line 15

def elementary_school_district
  @elementary_school_district
end

#formatted_streetObject (readonly)

Returns the value of attribute formatted_street


8
9
10
# File 'lib/geocodio/address.rb', line 8

def formatted_street
  @formatted_street
end

#house_districtObject (readonly)

Returns the value of attribute house_district


15
16
17
# File 'lib/geocodio/address.rb', line 15

def house_district
  @house_district
end

#latitudeObject (readonly) Also known as: lat

Returns the value of attribute latitude


11
12
13
# File 'lib/geocodio/address.rb', line 11

def latitude
  @latitude
end

#longitudeObject (readonly) Also known as: lng

Returns the value of attribute longitude


11
12
13
# File 'lib/geocodio/address.rb', line 11

def longitude
  @longitude
end

#numberObject (readonly)

Returns the value of attribute number


8
9
10
# File 'lib/geocodio/address.rb', line 8

def number
  @number
end

#postdirectionalObject (readonly)

Returns the value of attribute postdirectional


8
9
10
# File 'lib/geocodio/address.rb', line 8

def postdirectional
  @postdirectional
end

#predirectionalObject (readonly)

Returns the value of attribute predirectional


8
9
10
# File 'lib/geocodio/address.rb', line 8

def predirectional
  @predirectional
end

#secondary_school_districtObject (readonly)

Returns the value of attribute secondary_school_district


15
16
17
# File 'lib/geocodio/address.rb', line 15

def secondary_school_district
  @secondary_school_district
end

#senate_districtObject (readonly)

Returns the value of attribute senate_district


15
16
17
# File 'lib/geocodio/address.rb', line 15

def senate_district
  @senate_district
end

#stateObject (readonly)

Returns the value of attribute state


8
9
10
# File 'lib/geocodio/address.rb', line 8

def state
  @state
end

#streetObject (readonly)

Returns the value of attribute street


8
9
10
# File 'lib/geocodio/address.rb', line 8

def street
  @street
end

#suffixObject (readonly)

Returns the value of attribute suffix


8
9
10
# File 'lib/geocodio/address.rb', line 8

def suffix
  @suffix
end

#timezoneObject (readonly)

Returns the value of attribute timezone


19
20
21
# File 'lib/geocodio/address.rb', line 19

def timezone
  @timezone
end

#unified_school_districtObject (readonly)

Returns the value of attribute unified_school_district


15
16
17
# File 'lib/geocodio/address.rb', line 15

def unified_school_district
  @unified_school_district
end

#zipObject (readonly)

Returns the value of attribute zip


8
9
10
# File 'lib/geocodio/address.rb', line 8

def zip
  @zip
end

Instance Method Details

#to_sString

Formats the address in the standard way.

Returns:

  • (String)

    a formatted address


38
39
40
# File 'lib/geocodio/address.rb', line 38

def to_s
  @formatted_address
end