Sha256: c363fe01f4a28bc1d4bb7bb1f062ee9ba17062b1457dc6e279e716727b242f0c

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

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

    # @attribute [rw] availability
    #   @return [Availability]
    attr_accessor :availability

    # @attribute [rw] dimensions
    #   @return [Dimensions]
    attr_accessor :dimensions

    # @attribute [rw] rates
    #   @return [Rates]
    attr_accessor :rates

    # @param uid [String]
    # @param availability [Availability]
    # @param dimensions [Dimensions]
    # @param rates [Rates]
    def initialize(uid:, availability:, dimensions:, rates:)
      @uid = uid
      @availability = availability
      @dimensions = dimensions
      @rates = rates
    end

    # @return [String]
    def inspect
      props = [
        "uid=#{@uid.inspect}",
        "availability=#{@availability.inspect}",
        "dimensions=#{@dimensions.inspect}",
        "rates=#{@rates.inspect}"
      ]
      "#<#{self.class.name} #{props.join(' ')}>"
    end

    # @param data [Hash]
    #
    # @return [Price]
    def self.parse(data:)
      availability = Availability.parse(data: data['availability'])
      dimensions = Dimensions.parse(data: data['dimensions'])
      rates = Rates.parse(data: data['rates'])
      new(
        uid: data['uid'],
        availability: availability,
        dimensions: dimensions,
        rates: rates
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
extraspace-0.1.1 lib/extraspace/price.rb