Class: UHaul::Geocode
- Inherits:
-
Object
- Object
- UHaul::Geocode
- Defined in:
- lib/uhaul/geocode.rb
Overview
The geocode (latitude + longitude) of a facility.
Constant Summary collapse
- LATITUDE_REGEX =
/\\u0022lat\\u0022:(?<latitude>[\+\-\d\.]+)/
- LONGITUDE_REGEX =
/\\u0022long\\u0022:(?<longitude>[\+\-\d\.]+)/
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(latitude:, longitude:) ⇒ Geocode
constructor
A new instance of Geocode.
- #inspect ⇒ String
- #text ⇒ String
Constructor Details
#initialize(latitude:, longitude:) ⇒ Geocode
Returns a new instance of Geocode.
29 30 31 32 |
# File 'lib/uhaul/geocode.rb', line 29 def initialize(latitude:, longitude:) @latitude = latitude @longitude = longitude end |
Instance Attribute Details
#latitude ⇒ Float
11 12 13 |
# File 'lib/uhaul/geocode.rb', line 11 def latitude @latitude end |
#longitude ⇒ Float
15 16 17 |
# File 'lib/uhaul/geocode.rb', line 15 def longitude @longitude end |
Class Method Details
.parse(data:) ⇒ Geocode
20 21 22 23 24 25 |
# File 'lib/uhaul/geocode.rb', line 20 def self.parse(data:) latitude = Float(data['latitude']) longitude = Float(data['longitude']) new(latitude:, longitude:) end |
Instance Method Details
#inspect ⇒ String
35 36 37 38 39 40 41 |
# File 'lib/uhaul/geocode.rb', line 35 def inspect props = [ "latitude=#{@latitude.inspect}", "longitude=#{@longitude.inspect}" ] "#<#{self.class.name} #{props.join(' ')}>" end |
#text ⇒ String
44 45 46 |
# File 'lib/uhaul/geocode.rb', line 44 def text "#{@latitude},#{@longitude}" end |