Sha256: 913e6edafd99b23542ce15de21313c3358c9216d40ea550989519123bf5a0c46
Contents?: true
Size: 889 Bytes
Versions: 7
Compression:
Stored size: 889 Bytes
Contents
module Kosher class Offer < Struct.new( :seller, :condition, :description, :ships_in, :ships_free, :cents) def self.build(doc) offer = new offer.seller = Seller.build(doc['Merchant']) attributes = doc['OfferAttributes'] offer.condition = Condition.new(attributes['SubCondition']) offer.description = Description.new(attributes['ConditionNote'].to_s) listing = doc['OfferListing'] offer.ships_in = listing['AvailabilityAttributes']['MaximumHours'].to_i offer.ships_free = listing['IsEligibleForSuperSaverShipping'] == '1' offer.cents = listing['Price']['Amount'].to_i offer end def kosher? condition.kosher? && seller.kosher? && description.kosher? && ships_now? end def ships_now? ships_in.to_i <= 48 end end end
Version data entries
7 entries across 7 versions & 1 rubygems