Class: CubeSmart::Geocode

Inherits:
Object
  • Object
show all
Defined in:
lib/cubesmart/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)


16
17
18
19
# File 'lib/cubesmart/geocode.rb', line 16

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

Instance Attribute Details

#latitudeFloat

Returns:

  • (Float)


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

def latitude
  @latitude
end

#longitudeFloat

Returns:

  • (Float)


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

def longitude
  @longitude
end

Class Method Details

.parse(data:) ⇒ Geocode

Parameters:

  • data (Hash)

Returns:



38
39
40
41
42
43
# File 'lib/cubesmart/geocode.rb', line 38

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

Instance Method Details

#inspectString

Returns:

  • (String)


22
23
24
25
26
27
28
# File 'lib/cubesmart/geocode.rb', line 22

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

#textString

Returns:

  • (String)


31
32
33
# File 'lib/cubesmart/geocode.rb', line 31

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