Class: PublicStorage::Rates

Inherits:
Object
  • Object
show all
Defined in:
lib/publicstorage/rates.rb

Overview

The rates (street + web) for a facility

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(street:, web:) ⇒ Rates

Returns a new instance of Rates.

Parameters:

  • street (Integer)
  • web (Integer)


16
17
18
19
# File 'lib/publicstorage/rates.rb', line 16

def initialize(street:, web:)
  @street = street
  @web = web
end

Instance Attribute Details

#streetInteger

Returns:

  • (Integer)


8
9
10
# File 'lib/publicstorage/rates.rb', line 8

def street
  @street
end

#webInteger

Returns:

  • (Integer)


12
13
14
# File 'lib/publicstorage/rates.rb', line 12

def web
  @web
end

Class Method Details

.parse(data:) ⇒ Rates

Parameters:

  • data (Hash)

Returns:



38
39
40
41
42
# File 'lib/publicstorage/rates.rb', line 38

def self.parse(data:)
  street = data['listprice']
  web = data['saleprice']
  new(street:, web:)
end

Instance Method Details

#inspectString

Returns:

  • (String)


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

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

#textString

Returns e.g. “$80 (street) | $60 (web)”.

Returns:

  • (String)

    e.g. “$80 (street) | $60 (web)”



31
32
33
# File 'lib/publicstorage/rates.rb', line 31

def text
  "$#{@street} (street) | $#{@web} (web)"
end