Sha256: 3ed8fd90ba4f027b66a70d189245acd4adfdbce2cf762c322ca8b49e2b33afc1

Contents?: true

Size: 587 Bytes

Versions: 3

Compression:

Stored size: 587 Bytes

Contents

module Kosher
  # Shipping details of an offer.
  #
  # Shipping costs something (or nothing) and is subject to availability.
  class Shipping < Structure
    key :cents, :type => Integer
    key :currency
    key :availability, :type => Structure

    # Returns whether the item ships for free.
    def free?
      cents == 0
    end

    # Returns true if the item is available to ship.
    def kosher?
      availability.kosher?
    end

    # The shipping cost.
    def cost
      raise TypeError, "Can't render money" unless cents
      Money.new(cents, currency)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kosher-0.5.0 lib/kosher/shipping.rb
kosher-0.4.0 lib/kosher/shipping.rb
kosher-0.3.0 lib/kosher/shipping.rb