Class: MiamiDadeGeo::Address
- Inherits:
-
Object
- Object
- MiamiDadeGeo::Address
- 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
-
#address ⇒ String
readonly
The street address.
-
#feature ⇒ Object
readonly
Returns the value of attribute feature.
-
#zip ⇒ Integer
The ZIP code of the address.
Class Method Summary collapse
-
.new_from_address(address) ⇒ Object
Construct the address object.
- .new_from_feature(feature) ⇒ Object
Instance Method Summary collapse
-
#coordinate ⇒ Coordinate
even is.
-
#lat ⇒ Float
The latitude of the address.
-
#long ⇒ Float
The longitude of the address.
-
#munic_code ⇒ Integer
The municipality code of the address.
-
#municipality ⇒ Municipality
Constructs and returns a Municipality object.
-
#x ⇒ Float
The x-coordinate of the address.
-
#y ⇒ Float
The y-coordinate of the address.
Instance Attribute Details
#address ⇒ String (readonly)
Returns the street address.
24 25 26 |
# File 'lib/miami_dade_geo/address.rb', line 24 def address @address end |
#feature ⇒ Object (readonly)
Returns the value of attribute feature.
20 21 22 |
# File 'lib/miami_dade_geo/address.rb', line 20 def feature @feature end |
#zip ⇒ Integer
Returns 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
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
#coordinate ⇒ Coordinate
even is
44 45 46 |
# File 'lib/miami_dade_geo/address.rb', line 44 def coordinate @coordinate ||= Coordinate.new xy_addr end |
#lat ⇒ Float
Returns the latitude of the address.
69 70 71 |
# File 'lib/miami_dade_geo/address.rb', line 69 def lat coordinate.lat end |
#long ⇒ Float
Returns the longitude of the address.
74 75 76 |
# File 'lib/miami_dade_geo/address.rb', line 74 def long coordinate.long end |
#munic_code ⇒ Integer
Returns 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 |
#municipality ⇒ Municipality
Constructs and returns a Municipality object. Makes one SOAP request.
80 81 82 |
# File 'lib/miami_dade_geo/address.rb', line 80 def municipality @municipality ||= Municipality.new_with_code(munic_code) end |
#x ⇒ Float
Returns the x-coordinate of the address.
49 50 51 |
# File 'lib/miami_dade_geo/address.rb', line 49 def x coordinate.x end |
#y ⇒ Float
Returns the y-coordinate of the address.
54 55 56 |
# File 'lib/miami_dade_geo/address.rb', line 54 def y coordinate.y end |