Class: ExtraSpace::Address
- Inherits:
-
Object
- Object
- ExtraSpace::Address
- Defined in:
- lib/extraspace/address.rb
Overview
The address (street + city + state + zip) of a facility.
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.
40 41 42 43 44 45 |
# File 'lib/extraspace/address.rb', line 40 def initialize(street:, city:, state:, zip:) @street = street @city = city @state = state @zip = zip end |
Instance Attribute Details
#city ⇒ String
12 13 14 |
# File 'lib/extraspace/address.rb', line 12 def city @city end |
#state ⇒ String
16 17 18 |
# File 'lib/extraspace/address.rb', line 16 def state @state end |
#street ⇒ String
8 9 10 |
# File 'lib/extraspace/address.rb', line 8 def street @street end |
#zip ⇒ String
20 21 22 |
# File 'lib/extraspace/address.rb', line 20 def zip @zip end |
Class Method Details
.parse(data:) ⇒ Address
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/extraspace/address.rb', line 25 def self.parse(data:) lines = %w[line1 line2 line3 line4].map { |key| data[key] } new( street: lines.compact.reject(&:empty?).join(' '), city: data['city'], state: data['stateName'], zip: data['postalCode'] ) end |
Instance Method Details
#inspect ⇒ String
48 49 50 51 52 53 54 55 56 |
# File 'lib/extraspace/address.rb', line 48 def inspect props = [ "street=#{@street.inspect}", "city=#{@city.inspect}", "state=#{@state.inspect}", "zip=#{@zip.inspect}" ] "#<#{self.class.name} #{props.join(' ')}>" end |
#text ⇒ String
59 60 61 |
# File 'lib/extraspace/address.rb', line 59 def text "#{street}, #{city}, #{state} #{zip}" end |