Sha256: 83c95d6708aee1ee83890d548fe5484782940de21b64aa562cdc7a6278397926

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

module ExtraSpace
  # e.g. https://www.extraspace.com/storage/facilities/us/alabama/auburn/3264/
  class Address
    # @attribute [rw] line1
    #   @return [String]
    attr_accessor :line1

    # @attribute [rw] line2
    #   @return [String]
    attr_accessor :line2

    # @attribute [rw] city
    #   @return [String]
    attr_accessor :city

    # @attribute [rw] state
    #   @return [String]
    attr_accessor :state

    # @attribute [rw] zip
    #   @return [String]
    attr_accessor :zip

    # @param line1 [String]
    # @param line2 [String]
    # @param city [String]
    # @param state_abbreviation [String]
    # @param state_name [String]
    # @param postal_code [String]
    def initialize(line1:, line2:, city:, state:, zip:)
      @line1 = line1
      @line2 = line2
      @city = city
      @state = state
      @zip = zip
    end

    def inspect
      props = [
        "line1=#{@line1.inspect}",
        "line2=#{@line2.inspect}",
        "city=#{@city.inspect}",
        "state=#{@state.inspect}",
        "zip=#{@zip.inspect}"
      ]
      "#<#{self.class.name} #{props.join(' ')}>"
    end

    # @param data [Hash]
    #
    # @return [Address]
    def self.parse(data:)
      new(
        line1: data['line1'],
        line2: data['line2'],
        city: data['city'],
        state: data['stateName'],
        zip: data['postalCode']
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
extraspace-0.1.0 lib/extraspace/address.rb