Class: UHaul::Address
- Inherits:
-
Object
- Object
- UHaul::Address
- Defined in:
- lib/uhaul/address.rb
Overview
The address (street + city + state + zip) of a facility.
Constant Summary collapse
- ADDRESS_SELECTOR =
'.item-des-box .text-box .part_title_1'
- ADDRESS_REGEX =
/(?<street>.+),\s+(?<city>.+),\s+(?<state>.+)\s+(?<zip>\d{5})/
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(street:, city:, state:, zip:) ⇒ Address
constructor
A new instance of Address.
- #inspect ⇒ String
- #text ⇒ String
Constructor Details
#initialize(street:, city:, state:, zip:) ⇒ Address
Returns a new instance of Address.
28 29 30 31 32 33 |
# File 'lib/uhaul/address.rb', line 28 def initialize(street:, city:, state:, zip:) @street = street @city = city @state = state @zip = zip end |
Instance Attribute Details
#city ⇒ String
14 15 16 |
# File 'lib/uhaul/address.rb', line 14 def city @city end |
#state ⇒ String
18 19 20 |
# File 'lib/uhaul/address.rb', line 18 def state @state end |
#street ⇒ String
10 11 12 |
# File 'lib/uhaul/address.rb', line 10 def street @street end |
#zip ⇒ String
22 23 24 |
# File 'lib/uhaul/address.rb', line 22 def zip @zip end |
Class Method Details
.parse(data:) ⇒ Address
54 55 56 57 58 59 60 61 |
# File 'lib/uhaul/address.rb', line 54 def self.parse(data:) new( street: data['streetAddress'], city: data['addressLocality'], state: data['addressRegion'], zip: data['postalCode'] ) end |
Instance Method Details
#inspect ⇒ String
36 37 38 39 40 41 42 43 44 |
# File 'lib/uhaul/address.rb', line 36 def inspect props = [ "street=#{@street.inspect}", "city=#{@city.inspect}", "state=#{@state.inspect}", "zip=#{@zip.inspect}" ] "#<#{self.class.name} #{props.join(' ')}>" end |
#text ⇒ String
47 48 49 |
# File 'lib/uhaul/address.rb', line 47 def text "#{street}, #{city}, #{state} #{zip}" end |