Class: CubeSmart::Features
- Inherits:
-
Object
- Object
- CubeSmart::Features
- Defined in:
- lib/cubesmart/features.rb
Overview
The features (e.g. climate-controlled, inside-drive-up-access, outside-drive-up-access, etc) of a price.
Class Method Summary collapse
Instance Method Summary collapse
- #amenities ⇒ Array<String>
- #climate_controlled? ⇒ Boolean
- #drive_up_access? ⇒ Boolean
- #first_floor_access? ⇒ Boolean
-
#initialize(climate_controlled:, inside_drive_up_access:, outside_drive_up_access:, first_floor_access:) ⇒ Features
constructor
A new instance of Features.
- #inside_drive_up_access? ⇒ Boolean
- #inspect ⇒ String
- #outside_drive_up_access? ⇒ Boolean
-
#text ⇒ String
E.g.
Constructor Details
#initialize(climate_controlled:, inside_drive_up_access:, outside_drive_up_access:, first_floor_access:) ⇒ Features
Returns a new instance of Features.
24 25 26 27 28 29 |
# File 'lib/cubesmart/features.rb', line 24 def initialize(climate_controlled:, inside_drive_up_access:, outside_drive_up_access:, first_floor_access:) @climate_controlled = climate_controlled @inside_drive_up_access = inside_drive_up_access @outside_drive_up_access = outside_drive_up_access @first_floor_access = first_floor_access end |
Class Method Details
.parse(element:) ⇒ Features
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cubesmart/features.rb', line 9 def self.parse(element:) text = element.text new( climate_controlled: text.include?('Climate controlled'), inside_drive_up_access: text.include?('Inside drive-up access'), outside_drive_up_access: text.include?('Outside drive-up access'), first_floor_access: text.include?('1st floor access') ) end |
Instance Method Details
#amenities ⇒ Array<String>
49 50 51 52 53 54 55 56 |
# File 'lib/cubesmart/features.rb', line 49 def amenities [].tap do |amenities| amenities << 'Climate Controlled' if climate_controlled? amenities << 'Inside Drive-Up Access' if inside_drive_up_access? amenities << 'Outside Drive-Up Access' if outside_drive_up_access? amenities << 'First Floor Access' if first_floor_access? end end |
#climate_controlled? ⇒ Boolean
59 60 61 |
# File 'lib/cubesmart/features.rb', line 59 def climate_controlled? @climate_controlled end |
#drive_up_access? ⇒ Boolean
74 75 76 |
# File 'lib/cubesmart/features.rb', line 74 def drive_up_access? inside_drive_up_access? || outside_drive_up_access? end |
#first_floor_access? ⇒ Boolean
79 80 81 |
# File 'lib/cubesmart/features.rb', line 79 def first_floor_access? @first_floor_access end |
#inside_drive_up_access? ⇒ Boolean
64 65 66 |
# File 'lib/cubesmart/features.rb', line 64 def inside_drive_up_access? @inside_drive_up_access end |
#inspect ⇒ String
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cubesmart/features.rb', line 32 def inspect props = [ "climate_controlled=#{@climate_controlled}", "inside_drive_up_access=#{@inside_drive_up_access}", "outside_drive_up_access=#{@outside_drive_up_access}", "first_floor_access=#{@first_floor_access}" ] "#<#{self.class.name} #{props.join(' ')}>" end |
#outside_drive_up_access? ⇒ Boolean
69 70 71 |
# File 'lib/cubesmart/features.rb', line 69 def outside_drive_up_access? @outside_drive_up_access end |
#text ⇒ String
Returns e.g. “Climate Controlled + First Floor Access”.
44 45 46 |
# File 'lib/cubesmart/features.rb', line 44 def text amenities.join(' + ') end |