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



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

def address
  @address
end

#featureObject (readonly)

Returns the value of attribute feature.



17
18
19
# File 'lib/miami_dade_geo/address.rb', line 17

def feature
  @feature
end

#zipInteger

Returns the ZIP code of the address.

Returns:

  • (Integer)

    the ZIP code of the address



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

def zip
  @zip
end

Class Method Details

.new_from_address(address) ⇒ Object

Construct the address object

Parameters:

  • address (String)

    the street address



29
30
31
32
33
# File 'lib/miami_dade_geo/address.rb', line 29

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

  Coordinate.new(xy).address
end

.new_from_feature(feature) ⇒ Object



35
36
37
# File 'lib/miami_dade_geo/address.rb', line 35

def self.new_from_feature(feature)
  new feature
end

Instance Method Details

#coordinateCoordinate

even is

Returns:

  • (Coordinate)

    a coordinate object representing where this address



41
42
43
# File 'lib/miami_dade_geo/address.rb', line 41

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

#latFloat

Returns the latitude of the address.

Returns:

  • (Float)

    the latitude of the address



66
67
68
# File 'lib/miami_dade_geo/address.rb', line 66

def lat
  coordinate.lat
end

#longFloat

Returns the longitude of the address.

Returns:

  • (Float)

    the longitude of the address



71
72
73
# File 'lib/miami_dade_geo/address.rb', line 71

def long
  coordinate.long
end

#munic_codeInteger

Returns the municipality code of the address.

Returns:

  • (Integer)

    the municipality code of the address



61
62
63
# File 'lib/miami_dade_geo/address.rb', line 61

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

#municipalityMunicipality

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

Returns:



77
78
79
# File 'lib/miami_dade_geo/address.rb', line 77

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



46
47
48
# File 'lib/miami_dade_geo/address.rb', line 46

def x
  coordinate.x
end

#yFloat

Returns the y-coordinate of the address.

Returns:

  • (Float)

    the y-coordinate of the address



51
52
53
# File 'lib/miami_dade_geo/address.rb', line 51

def y
  coordinate.y
end