Class: Geocodio::Address

Inherits:
Object
  • Object
show all
Includes:
Canadian, UK
Defined in:
lib/geocodio/address.rb

Instance Attribute Summary collapse

Attributes included from UK

#uk_devolved, #uk_local, #uk_westminster

Attributes included from Canadian

#canadian

Instance Method Summary collapse

Methods included from UK

#set_uk_fields, #uk?, #uk_fields?

Methods included from Canadian

#canadian?, #set_canadian_fields

Constructor Details

#initialize(payload = {}) ⇒ Address

Returns a new instance of Address.



31
32
33
34
35
36
37
38
39
40
# File 'lib/geocodio/address.rb', line 31

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']

  @source            = payload['source']
  @accuracy          = payload['accuracy']
  @accuracy_type     = payload['accuracy_type']
  @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



29
30
31
# File 'lib/geocodio/address.rb', line 29

def accuracy
  @accuracy
end

#accuracy_typeFloat (readonly)

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

Returns:

  • (Float)

    a number between 0 and 1



29
30
31
# File 'lib/geocodio/address.rb', line 29

def accuracy_type
  @accuracy_type
end

#cityObject (readonly)

Returns the value of attribute city.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def city
  @city
end

#congressional_districtsObject (readonly)

Returns the value of attribute congressional_districts.



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

def congressional_districts
  @congressional_districts
end

#countyObject (readonly)

Returns the value of attribute county.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def county
  @county
end

#elementary_school_districtObject (readonly)

Returns the value of attribute elementary_school_district.



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

def elementary_school_district
  @elementary_school_district
end

#formatted_streetObject (readonly)

Returns the value of attribute formatted_street.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def formatted_street
  @formatted_street
end

#house_districtsObject (readonly)

Returns the value of attribute house_districts.



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

def house_districts
  @house_districts
end

#latitudeObject (readonly) Also known as: lat

Returns the value of attribute latitude.



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

def latitude
  @latitude
end

#longitudeObject (readonly) Also known as: lng

Returns the value of attribute longitude.



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

def longitude
  @longitude
end

#numberObject (readonly)

Returns the value of attribute number.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def number
  @number
end

#postdirectionalObject (readonly)

Returns the value of attribute postdirectional.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def postdirectional
  @postdirectional
end

#predirectionalObject (readonly)

Returns the value of attribute predirectional.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def predirectional
  @predirectional
end

#secondary_school_districtObject (readonly)

Returns the value of attribute secondary_school_district.



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

def secondary_school_district
  @secondary_school_district
end

#senate_districtsObject (readonly)

Returns the value of attribute senate_districts.



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

def senate_districts
  @senate_districts
end

#sourceFloat (readonly)

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

Returns:

  • (Float)

    a number between 0 and 1



29
30
31
# File 'lib/geocodio/address.rb', line 29

def source
  @source
end

#stateObject (readonly)

Returns the value of attribute state.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def state
  @state
end

#streetObject (readonly)

Returns the value of attribute street.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def street
  @street
end

#suffixObject (readonly)

Returns the value of attribute suffix.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def suffix
  @suffix
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



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

def timezone
  @timezone
end

#unified_school_districtObject (readonly)

Returns the value of attribute unified_school_district.



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

def unified_school_district
  @unified_school_district
end

#zipObject (readonly)

Returns the value of attribute zip.



13
14
15
# File 'lib/geocodio/address.rb', line 13

def zip
  @zip
end

Instance Method Details

#to_sString

Formats the address in the standard way.

Returns:

  • (String)

    a formatted address



45
46
47
# File 'lib/geocodio/address.rb', line 45

def to_s
  @formatted_address
end