Sha256: f7f5739172c45ebf854e893dc4ea871899a0a525fc4124f074fa3b7d2a39e9d8

Contents?: true

Size: 437 Bytes

Versions: 2

Compression:

Stored size: 437 Bytes

Contents

module Kosher
  class Offer < Structure
    include Comparable

    one :condition
    one :shipping
    one :seller
    one :unit
    one :venue

    def <=>(other)
      if kosher? != other.kosher?
        kosher? ? -1 : 1
      else
        price <=> other.price
      end
    end

    def kosher?
      condition.kosher? && seller.kosher? && shipping.kosher?
    end

    def price
      unit.price + shipping.cost
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kosher-0.17.1 lib/kosher/offer.rb
kosher-0.17.0 lib/kosher/offer.rb