Sha256: 50995de72152daba8b809e024b899d0c2644589a91ae91b3db8938dc32d520ac

Contents?: true

Size: 811 Bytes

Versions: 8

Compression:

Stored size: 811 Bytes

Contents

# frozen_string_literal: true

module FreightKit
  # Class representing a price.
  #
  # @!attribute blame
  #   Where did the cost come from?
  #   @return [Symbol] One of :api, :library, :tariff
  #
  # @!attribute description
  #   Description.
  #   @return [String]
  #
  # @!attribute objects
  #   Array of objects that the price applies to.
  #   @return [Array]
  #
  # @!attribute cents
  #   The price in cents.
  #   @return [Integer]
  #
  class Price < Model
    attr_accessor :description, :objects
    attr_writer :blame, :cents

    def blame
      return @blame if %i[api library tariff].include?(@blame)

      raise 'blame must be one of :api, :library, :tariff'
    end

    def cents
      return @cents if @cents.is_a?(Integer)

      raise 'cents must be an `Integer`'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
freight_kit-0.1.11 lib/freight_kit/models/price.rb
freight_kit-0.1.10 lib/freight_kit/models/price.rb
freight_kit-0.1.7 lib/freight_kit/models/price.rb
freight_kit-0.1.4 lib/freight_kit/models/price.rb
freight_kit-0.1.3 lib/freight_kit/models/price.rb
freight_kit-0.1.2 lib/freight_kit/models/price.rb
freight_kit-0.1.1 lib/freight_kit/models/price.rb
freight_kit-0.1.0 lib/freight_kit/models/price.rb