Sha256: a01d6a6cf1bfdbf34ca2efc3fa7c54a0372d5f0cab71365fe53e150afca4b064

Contents?: true

Size: 510 Bytes

Versions: 3

Compression:

Stored size: 510 Bytes

Contents

module Kosher

  # The actual item offered by a seller.
  #
  # An item has a price, quantity, condition, and description.
  class Item < Structure
    key :cents, :type => Integer
    key :currency
    key :quantity, :type => Integer
    key :condition, :type => Structure
    key :description, :type => Structure

    def kosher?
      condition.kosher? && description.kosher?
    end

    def price
      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/item.rb
kosher-0.4.0 lib/kosher/item.rb
kosher-0.3.0 lib/kosher/item.rb