Class: MiamiDadeGeo::Address

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

Overview

A street address in Miami-Dade County. Lazily makes up to two SOAP requests: one to get the X and Y coordinates, and one to convert them to standard latitude and longitude.

Can raise an [InvalidAddressError] when lazily making the initial SOAP request if the given address does not exist.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressString (readonly)

Returns the street address.

Returns:

  • (String)

    the street address



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

def address
  @address
end

#featureObject (readonly)

Returns the value of attribute feature.



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

def feature
  @feature
end

#zipInteger

Returns the ZIP code of the address.

Returns:

  • (Integer)

    the ZIP code of the address



28
29
30
# File 'lib/miami_dade_geo/address.rb', line 28

def zip
  @zip
end

Class Method Details

.new_from_address(address) ⇒ Object

Construct the address object

Parameters:

  • address (String)

    the street address



32
33
34
35
36
# File 'lib/miami_dade_geo/address.rb', line 32

def self.new_from_address(address)
  xy = AddrXyClient.instance.xy_for_address(address)

  Coordinate.new(xy).address
end

.new_from_feature(feature) ⇒ Object



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

def self.new_from_feature(feature)
  new feature
end

Instance Method Details

#coordinateCoordinate

even is

Returns:

  • (Coordinate)

    a coordinate object representing where this address



44
45
46
# File 'lib/miami_dade_geo/address.rb', line 44

def coordinate
  @coordinate ||= Coordinate.new xy_addr
end

#latFloat

Returns the latitude of the address.

Returns:

  • (Float)

    the latitude of the address



69
70
71
# File 'lib/miami_dade_geo/address.rb', line 69

def lat
  coordinate.lat
end

#longFloat

Returns the longitude of the address.

Returns:

  • (Float)

    the longitude of the address



74
75
76
# File 'lib/miami_dade_geo/address.rb', line 74

def long
  coordinate.long
end

#munic_codeInteger

Returns the municipality code of the address.

Returns:

  • (Integer)

    the municipality code of the address



64
65
66
# File 'lib/miami_dade_geo/address.rb', line 64

def munic_code
  @munic_code ||= xy_addr[:munic_code].to_i
end

#municipalityMunicipality

Constructs and returns a Municipality object. Makes one SOAP request.

Returns:



80
81
82
# File 'lib/miami_dade_geo/address.rb', line 80

def municipality
  @municipality ||= Municipality.new_with_code(munic_code)
end

#xFloat

Returns the x-coordinate of the address.

Returns:

  • (Float)

    the x-coordinate of the address



49
50
51
# File 'lib/miami_dade_geo/address.rb', line 49

def x
  coordinate.x
end

#yFloat

Returns the y-coordinate of the address.

Returns:

  • (Float)

    the y-coordinate of the address



54
55
56
# File 'lib/miami_dade_geo/address.rb', line 54

def y
  coordinate.y
end