publicstorage 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24f5bb4366cb716cf259fb43e0df167617389a71bbcffa20c2e3534c588b06c1
4
- data.tar.gz: 5b3be4bad58043fdfe30dee4067935bfc2346b778c967231155b670490a08d70
3
+ metadata.gz: 289fa9cafef0fbd579e585804481315f664daa8e2366d0af7e29e6e8ca36e2a8
4
+ data.tar.gz: d3ae363cef7d78466aa500774273910d16eda47cd6305842279636d492bf005f
5
5
  SHA512:
6
- metadata.gz: e117b9fa84c46cbae5a14756cb4f5926a6a1405a91be4963c112fbe2c22d71f8090a33df5ad4b7c9a9126c64c09b524caaa01a1e10c58975d98b5ee593f22a4e
7
- data.tar.gz: 15e95167c0d18276093a62594d95c13b9d2be48276541045c3b683b14748fbe65f38d43e58aeb609e75c3dc98cd82dc688d54d8a22aeb7ebbc514d4dd5e90dbd
6
+ metadata.gz: 197fd2db249b2a5022219e7f2e25ac88c4461370ef757e534e273460fe6a13f261a151e541a60a48de591c9c56380f8c1a71c190d079816cbcf0759abe27dfd4
7
+ data.tar.gz: 11985f88d43d959569dcf396c92e0b17cee9347a22058f1642389f7954880cbde9d0676540356bf8005eafbdc2d3c6f3938619a5d2b7b370090362998f1b6dea
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PublicStorage
4
+ # The features (e.g. climate-controlled, inside-drive-up-access, outside-drive-up-access, etc) of a price.
5
+ class Features
6
+ # @param data [Hash]
7
+ #
8
+ # @return [Features]
9
+ def self.parse(data:)
10
+ features = data['features']
11
+ new(
12
+ climate_controlled: features&.include?('climate controlled'),
13
+ drive_up_access: features&.include?('drive-up access'),
14
+ first_floor_access: features&.include?('1st floor')
15
+ )
16
+ end
17
+
18
+ # @param climate_controlled [Boolean]
19
+ # @param drive_up_access [Boolean]
20
+ # @param first_floor_access [Boolean]
21
+ def initialize(climate_controlled:, drive_up_access:, first_floor_access:)
22
+ @climate_controlled = climate_controlled
23
+ @drive_up_access = drive_up_access
24
+ @first_floor_access = first_floor_access
25
+ end
26
+
27
+ # @return [String]
28
+ def inspect
29
+ props = [
30
+ "climate_controlled=#{@climate_controlled}",
31
+ "drive_up_access=#{@drive_up_access}",
32
+ "first_floor_access=#{@first_floor_access}"
33
+ ]
34
+
35
+ "#<#{self.class.name} #{props.join(' ')}>"
36
+ end
37
+
38
+ # @return [String] e.g. "Climate Controlled + First Floor Access"
39
+ def text
40
+ amenities.join(' + ')
41
+ end
42
+
43
+ # @return [Array<String>]
44
+ def amenities
45
+ [].tap do |amenities|
46
+ amenities << 'Climate Controlled' if climate_controlled?
47
+ amenities << 'Drive-Up Access' if drive_up_access?
48
+ amenities << 'First Floor Access' if first_floor_access?
49
+ end
50
+ end
51
+
52
+ # @return [Boolean]
53
+ def climate_controlled?
54
+ @climate_controlled
55
+ end
56
+
57
+ # @return [Boolean]
58
+ def drive_up_access?
59
+ @drive_up_access
60
+ end
61
+
62
+ # @return [Boolean]
63
+ def first_floor_access?
64
+ @first_floor_access
65
+ end
66
+ end
67
+ end
@@ -13,16 +13,22 @@ module PublicStorage
13
13
  # @return [Dimensions]
14
14
  attr_accessor :dimensions
15
15
 
16
+ # @attribute [rw] features
17
+ # @return [Features]
18
+ attr_accessor :features
19
+
16
20
  # @attribute [rw] rates
17
21
  # @return [Rates]
18
22
  attr_accessor :rates
19
23
 
20
24
  # @param id [String]
21
25
  # @param dimensions [Dimensions]
26
+ # @param features [Features]
22
27
  # @param rates [Rates]
23
- def initialize(id:, dimensions:, rates:)
28
+ def initialize(id:, dimensions:, features:, rates:)
24
29
  @id = id
25
30
  @dimensions = dimensions
31
+ @features = features
26
32
  @rates = rates
27
33
  end
28
34
 
@@ -31,14 +37,15 @@ module PublicStorage
31
37
  props = [
32
38
  "id=#{@id.inspect}",
33
39
  "dimensions=#{@dimensions.inspect}",
40
+ "features=#{@features.inspect}",
34
41
  "rates=#{@rates.inspect}"
35
42
  ]
36
43
  "#<#{self.class.name} #{props.join(' ')}>"
37
44
  end
38
45
 
39
- # @return [String] e.g. "123 | 5' × 5' (25 sqft) | $100 (street) / $90 (web)"
46
+ # @return [String] e.g. "123 | 5' × 5' (25 sqft) | $100 (street) / $90 (web) | Climate Controlled"
40
47
  def text
41
- "#{@id} | #{@dimensions.text} | #{@rates.text}"
48
+ "#{@id} | #{@dimensions.text} | #{@rates.text} | #{@features.text}"
42
49
  end
43
50
 
44
51
  # @param element [Nokogiri::XML::Element]
@@ -49,10 +56,12 @@ module PublicStorage
49
56
 
50
57
  rates = Rates.parse(data:)
51
58
  dimensions = Dimensions.parse(data:)
59
+ features = Features.parse(data:)
52
60
 
53
61
  new(
54
62
  id: element.attr('data-unitid'),
55
63
  dimensions: dimensions,
64
+ features: features,
56
65
  rates: rates
57
66
  )
58
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PublicStorage
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publicstorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
@@ -87,6 +87,7 @@ files:
87
87
  - lib/publicstorage/crawler.rb
88
88
  - lib/publicstorage/dimensions.rb
89
89
  - lib/publicstorage/facility.rb
90
+ - lib/publicstorage/features.rb
90
91
  - lib/publicstorage/fetch_error.rb
91
92
  - lib/publicstorage/geocode.rb
92
93
  - lib/publicstorage/link.rb
@@ -100,8 +101,8 @@ licenses:
100
101
  metadata:
101
102
  rubygems_mfa_required: 'true'
102
103
  homepage_uri: https://github.com/ksylvest/publicstorage
103
- source_code_uri: https://github.com/ksylvest/publicstorage/tree/v1.2.0
104
- changelog_uri: https://github.com/ksylvest/publicstorage/releases/tag/v1.2.0
104
+ source_code_uri: https://github.com/ksylvest/publicstorage/tree/v1.3.0
105
+ changelog_uri: https://github.com/ksylvest/publicstorage/releases/tag/v1.3.0
105
106
  documentation_uri: https://publicstorage.ksylvest.com/
106
107
  post_install_message:
107
108
  rdoc_options: []