Class: CubeSmart::Price

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



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

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/cubesmart/price.rb', line 12

def dimensions
  @dimensions
end

#featuresFeatures

Returns:



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

def features
  @features
end

#idString

Returns:

  • (String)


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

def id
  @id
end

#ratesRates

Returns:



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

def rates
  @rates
end

Class Method Details

.parse(element:) ⇒ Price

Parameters:

  • element (Nokogiri::XML::Element)

Returns:



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

def self.parse(element:)
  new(
    id: element.attr('id'),
    dimensions: Dimensions.parse(element:),
    features: Features.parse(element:),
    rates: Rates.parse(element:)
  )
end

Instance Method Details

#inspectString

Returns:

  • (String)


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

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)”



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

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