Class: UHaul::Rates
- Inherits:
-
Object
- Object
- UHaul::Rates
- Defined in:
- lib/uhaul/rates.rb
Overview
The rates (street + web) for a facility
Constant Summary collapse
- RATE_REGEX =
/\$(?<price>[\d\.\,]+) Per Month/
Instance Attribute Summary collapse
-
#price ⇒ Object
(also: #street, #web)
Returns the value of attribute price.
- #rate ⇒ Integer
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(price:) ⇒ Rates
constructor
A new instance of Rates.
- #inspect ⇒ String
-
#text ⇒ String
E.g.
Constructor Details
#initialize(price:) ⇒ Rates
Returns a new instance of Rates.
26 27 28 |
# File 'lib/uhaul/rates.rb', line 26 def initialize(price:) @price = price end |
Instance Attribute Details
#price ⇒ Object Also known as: street, web
Returns the value of attribute price.
10 11 12 |
# File 'lib/uhaul/rates.rb', line 10 def price @price end |
#rate ⇒ Integer
10 |
# File 'lib/uhaul/rates.rb', line 10 attr_accessor :price |
Class Method Details
.parse(text:) ⇒ Rates
18 19 20 21 22 |
# File 'lib/uhaul/rates.rb', line 18 def self.parse(text:) price = Float(RATE_REGEX.match(text)[:price].gsub(',', '')) new(price:) end |
Instance Method Details
#inspect ⇒ String
31 32 33 |
# File 'lib/uhaul/rates.rb', line 31 def inspect "#<#{self.class.name} price=#{@price.inspect}>" end |
#text ⇒ String
Returns e.g. “$80”.
36 37 38 |
# File 'lib/uhaul/rates.rb', line 36 def text "$#{@price}" end |