Class: ExtraSpace::Geocode

Inherits:
Object
  • Object
show all
Defined in:
lib/extraspace/geocode.rb

Overview

The geocode (latitude + longitude) of a facility.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latitude:, longitude:) ⇒ Geocode

Returns a new instance of Geocode.

Parameters:

  • latitude (Float)
  • longitude (Float)


26
27
28
29
# File 'lib/extraspace/geocode.rb', line 26

def initialize(latitude:, longitude:)
  @latitude = latitude
  @longitude = longitude
end

Instance Attribute Details

#latitudeFloat

Returns:

  • (Float)


8
9
10
# File 'lib/extraspace/geocode.rb', line 8

def latitude
  @latitude
end

#longitudeFloat

Returns:

  • (Float)


12
13
14
# File 'lib/extraspace/geocode.rb', line 12

def longitude
  @longitude
end

Class Method Details

.parse(data:) ⇒ Geocode

Parameters:

  • data (Hash)

Returns:



17
18
19
20
21
22
# File 'lib/extraspace/geocode.rb', line 17

def self.parse(data:)
  new(
    latitude: data['latitude'],
    longitude: data['longitude']
  )
end

Instance Method Details

#inspectString

Returns:

  • (String)


32
33
34
35
36
37
38
# File 'lib/extraspace/geocode.rb', line 32

def inspect
  props = [
    "latitude=#{@latitude.inspect}",
    "longitude=#{@longitude.inspect}"
  ]
  "#<#{self.class.name} #{props.join(' ')}>"
end

#textString

Returns:

  • (String)


41
42
43
# File 'lib/extraspace/geocode.rb', line 41

def text
  "#{@latitude},#{@longitude}"
end