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.
21 22 23 |
# File 'lib/miami_dade_geo/address.rb', line 21 def address @address end |
#feature ⇒ Object (readonly)
Returns the value of attribute feature.
17 18 19 |
# File 'lib/miami_dade_geo/address.rb', line 17 def feature @feature end |
#zip ⇒ Integer
Returns 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
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
#coordinate ⇒ Coordinate
even is
41 42 43 |
# File 'lib/miami_dade_geo/address.rb', line 41 def coordinate @coordinate ||= Coordinate.new xy_addr end |
#lat ⇒ Float
Returns the latitude of the address.
66 67 68 |
# File 'lib/miami_dade_geo/address.rb', line 66 def lat coordinate.lat end |
#long ⇒ Float
Returns the longitude of the address.
71 72 73 |
# File 'lib/miami_dade_geo/address.rb', line 71 def long coordinate.long end |
#munic_code ⇒ Integer
Returns 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 |
#municipality ⇒ Municipality
Constructs and returns a Municipality object. Makes one SOAP request.
77 78 79 |
# File 'lib/miami_dade_geo/address.rb', line 77 def municipality @municipality ||= Municipality.new_with_code(munic_code) end |
#x ⇒ Float
Returns the x-coordinate of the address.
46 47 48 |
# File 'lib/miami_dade_geo/address.rb', line 46 def x coordinate.x end |
#y ⇒ Float
Returns the y-coordinate of the address.
51 52 53 |
# File 'lib/miami_dade_geo/address.rb', line 51 def y coordinate.y end |