Class: CubeSmart::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/cubesmart/address.rb

Overview

The address (street + city + state + zip) of a facility.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(street:, city:, state:, zip:) ⇒ Address

Returns a new instance of Address.

Parameters:

  • street (String)
  • city (String)
  • state (String)
  • zip (String)


26
27
28
29
30
31
# File 'lib/cubesmart/address.rb', line 26

def initialize(street:, city:, state:, zip:)
  @street = street
  @city = city
  @state = state
  @zip = zip
end

Instance Attribute Details

#cityString

Returns:

  • (String)


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

def city
  @city
end

#stateString

Returns:

  • (String)


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

def state
  @state
end

#streetString

Returns:

  • (String)


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

def street
  @street
end

#zipString

Returns:

  • (String)


20
21
22
# File 'lib/cubesmart/address.rb', line 20

def zip
  @zip
end

Class Method Details

.parse(data:) ⇒ Address

Parameters:

  • data (Hash)

Returns:



52
53
54
55
56
57
58
59
# File 'lib/cubesmart/address.rb', line 52

def self.parse(data:)
  new(
    street: data['streetAddress'],
    city: data['addressLocality'],
    state: data['addressRegion'],
    zip: data['postalCode']
  )
end

Instance Method Details

#inspectString

Returns:

  • (String)


34
35
36
37
38
39
40
41
42
# File 'lib/cubesmart/address.rb', line 34

def inspect
  props = [
    "street=#{@street.inspect}",
    "city=#{@city.inspect}",
    "state=#{@state.inspect}",
    "zip=#{@zip.inspect}"
  ]
  "#<#{self.class.name} #{props.join(' ')}>"
end

#textString

Returns:

  • (String)


45
46
47
# File 'lib/cubesmart/address.rb', line 45

def text
  "#{street}, #{city}, #{state} #{zip}"
end