Sha256: 5a2b6146043862657ab1593fa1ba695287b6809ff3fd127a1c71d93e2fc5765e

Contents?: true

Size: 424 Bytes

Versions: 1

Compression:

Stored size: 424 Bytes

Contents

module Kosher
  class Offer < Structure
    include Comparable

    key :kosher, Boolean
    key :new, Boolean
    key :shipping, Shipping
    key :seller
    key :unit, Unit

    alias kosher? kosher
    alias new? new

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kosher-0.16.0 lib/kosher/offer.rb