uhaul 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uhaul/price.rb +1 -13
- data/lib/uhaul/rates.rb +2 -2
- data/lib/uhaul/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4acc4dc138e904232902f124d9ee0c78923dc74c609c42515b97e83cdeea3fb2
|
4
|
+
data.tar.gz: 9e98885feb0367400d6a444f191b859d2e54abf646c9dda26938545f0d2bf8c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ecf98d2ab243fe983f6ef926c6fd425d988676173892a92990845b489561de61525ea30653d66c1b9d5956842006901064847c46aba4c5b9894c8f1a2846940
|
7
|
+
data.tar.gz: dde69a5ed918065d156872112b37b6d67b6f04a462f18f492da53ca7ecd56224ad38d1659f9e0b2bfa86f7e2f79684a0f7cdf391e1dbbece994e80dfec480e40
|
data/lib/uhaul/price.rb
CHANGED
@@ -22,18 +22,6 @@ module UHaul
|
|
22
22
|
# @return [Rates]
|
23
23
|
attr_accessor :rates
|
24
24
|
|
25
|
-
# @param facility_id [Integer]
|
26
|
-
#
|
27
|
-
# @return [Array<Price>]
|
28
|
-
def self.fetch(facility_id:)
|
29
|
-
url = "https://www.uhaul.com/facility-units/#{facility_id}"
|
30
|
-
data = Crawler.json(url:)['data']
|
31
|
-
return [] if data['error']
|
32
|
-
|
33
|
-
html = data['html']['units']
|
34
|
-
Nokogiri::HTML(html).css(PRICE_SELECTOR).map { |element| parse(element:) }
|
35
|
-
end
|
36
|
-
|
37
25
|
# @param id [String]
|
38
26
|
# @param dimensions [Dimensions]
|
39
27
|
# @param features [Features]
|
@@ -56,7 +44,7 @@ module UHaul
|
|
56
44
|
"#<#{self.class.name} #{props.join(' ')}>"
|
57
45
|
end
|
58
46
|
|
59
|
-
# @return [String] e.g. "123 | 5' × 5' (25 sqft) | $
|
47
|
+
# @return [String] e.g. "123 | 5' × 5' (25 sqft) | $90"
|
60
48
|
def text
|
61
49
|
"#{@id} | #{@dimensions.text} | #{@rates.text} | #{@features.text}"
|
62
50
|
end
|
data/lib/uhaul/rates.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module UHaul
|
4
4
|
# The rates (street + web) for a facility
|
5
5
|
class Rates
|
6
|
-
RATE_REGEX = /\$(?<price>[\d
|
6
|
+
RATE_REGEX = /\$(?<price>[\d\.\,]+) Per Month/
|
7
7
|
|
8
8
|
# @attribute [rw] rate
|
9
9
|
# @return [Integer]
|
@@ -16,7 +16,7 @@ module UHaul
|
|
16
16
|
#
|
17
17
|
# @return [Rates]
|
18
18
|
def self.parse(text:)
|
19
|
-
price = Float(RATE_REGEX.match(text)[:price])
|
19
|
+
price = Float(RATE_REGEX.match(text)[:price].gsub(',', ''))
|
20
20
|
|
21
21
|
new(price:)
|
22
22
|
end
|
data/lib/uhaul/version.rb
CHANGED