Class: NSAStorage::Features
- Inherits:
-
Object
- Object
- NSAStorage::Features
- Defined in:
- lib/nsastorage/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
-
#id ⇒ String
E.g.
-
#initialize(climate_controlled:, drive_up_access:, first_floor_access:) ⇒ Features
constructor
A new instance of Features.
- #inspect ⇒ String
-
#text ⇒ String
E.g.
Constructor Details
#initialize(climate_controlled:, drive_up_access:, first_floor_access:) ⇒ Features
Returns a new instance of Features.
22 23 24 25 26 |
# File 'lib/nsastorage/features.rb', line 22 def initialize(climate_controlled:, drive_up_access:, first_floor_access:) @climate_controlled = climate_controlled @drive_up_access = 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 |
# File 'lib/nsastorage/features.rb', line 9 def self.parse(element:) text = element.text new( climate_controlled: text.include?('Heated and Cooled'), drive_up_access: text.include?('Drive Up Access'), first_floor_access: text.include?('1st Floor') ) end |
Instance Method Details
#amenities ⇒ Array<String>
54 55 56 57 58 59 60 |
# File 'lib/nsastorage/features.rb', line 54 def amenities [].tap do |amenities| amenities << 'Climate Controlled' if climate_controlled? amenities << 'Drive-Up Access' if drive_up_access? amenities << 'First Floor Access' if first_floor_access? end end |
#climate_controlled? ⇒ Boolean
63 64 65 |
# File 'lib/nsastorage/features.rb', line 63 def climate_controlled? @climate_controlled end |
#drive_up_access? ⇒ Boolean
68 69 70 |
# File 'lib/nsastorage/features.rb', line 68 def drive_up_access? @drive_up_access end |
#first_floor_access? ⇒ Boolean
73 74 75 |
# File 'lib/nsastorage/features.rb', line 73 def first_floor_access? @first_floor_access end |
#id ⇒ String
Returns e.g. “”.
40 41 42 43 44 45 46 |
# File 'lib/nsastorage/features.rb', line 40 def id [].tap do |ids| ids << 'cc' if climate_controlled? ids << 'dua' if drive_up_access? ids << 'ffa' if first_floor_access? end.join('-') end |
#inspect ⇒ String
29 30 31 32 33 34 35 36 37 |
# File 'lib/nsastorage/features.rb', line 29 def inspect props = [ "climate_controlled=#{@climate_controlled}", "drive_up_access=#{@drive_up_access}", "first_floor_access=#{@first_floor_access}" ] "#<#{self.class.name} #{props.join(' ')}>" end |
#text ⇒ String
Returns e.g. “Climate Controlled + First Floor Access”.
49 50 51 |
# File 'lib/nsastorage/features.rb', line 49 def text amenities.join(' + ') end |