Class: ExtraSpace::Price

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

Overview

The price (id + dimensions + rate) for a facility

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, dimensions:, features:, rates:) ⇒ Price

Returns a new instance of Price.

Parameters:



38
39
40
41
42
43
# File 'lib/extraspace/price.rb', line 38

def initialize(id:, dimensions:, features:, rates:)
  @id = id
  @dimensions = dimensions
  @features = features
  @rates = rates
end

Instance Attribute Details

#dimensionsDimensions

Returns:



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

def dimensions
  @dimensions
end

#featuresFeatures

Returns:



16
17
18
# File 'lib/extraspace/price.rb', line 16

def features
  @features
end

#idString

Returns:

  • (String)


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

def id
  @id
end

#ratesRates

Returns:



20
21
22
# File 'lib/extraspace/price.rb', line 20

def rates
  @rates
end

Class Method Details

.parse(data:) ⇒ Price

Parameters:

  • data (Hash)

Returns:



25
26
27
28
29
30
31
32
# File 'lib/extraspace/price.rb', line 25

def self.parse(data:)
  new(
    id: data['uid'],
    dimensions: Dimensions.parse(data: data['dimensions']),
    features: Features.parse(data: data['features']),
    rates: Rates.parse(data: data['rates'])
  )
end

Instance Method Details

#inspectString

Returns:

  • (String)


46
47
48
49
50
51
52
53
54
# File 'lib/extraspace/price.rb', line 46

def inspect
  props = [
    "id=#{@id.inspect}",
    "dimensions=#{@dimensions.inspect}",
    "features=#{@features.inspect}",
    "rates=#{@rates.inspect}"
  ]
  "#<#{self.class.name} #{props.join(' ')}>"
end

#textString

Returns e.g. “123 | 5’ × 5’ (25 sqft) | $100 (street) / $90 (web)”.

Returns:

  • (String)

    e.g. “123 | 5’ × 5’ (25 sqft) | $100 (street) / $90 (web)”



57
58
59
# File 'lib/extraspace/price.rb', line 57

def text
  "#{@id} | #{@dimensions.text} | #{@rates.text}"
end