Class: Dustbag::Offer

Inherits:
Object
  • Object
show all
Includes:
Parser::Node
Defined in:
lib/dustbag/offer.rb

Instance Attribute Summary

Attributes included from Parser::Node

#node, #subnodes

Instance Method Summary collapse

Methods included from Parser::Node

included, #initialize, #repeated_subnodes, #repeated_subnodes_text, #subnode, #subnode_text

Instance Method Details

#amount_savedObject



21
22
23
24
# File 'lib/dustbag/offer.rb', line 21

def amount_saved
  savings = offer_listing && offer_listing.locate('AmountSaved').first
  Price.parse(savings)
end

#availabilityObject



26
27
28
29
# File 'lib/dustbag/offer.rb', line 26

def availability
  availability = offer_listing && offer_listing.locate('Availability').first
  availability && availability.text
end

#availability_attributesObject



41
42
43
44
# File 'lib/dustbag/offer.rb', line 41

def availability_attributes
  availability = offer_listing && offer_listing.locate('AvailabilityAttributes').first
  AvailabilityAttributes.new(availability)
end

#conditionObject



5
6
7
8
9
# File 'lib/dustbag/offer.rb', line 5

def condition
  offer_attrs = subnode('OfferAttributes')
  condition   = offer_attrs && offer_attrs.locate('Condition').first
  condition && condition.text
end

#eligible_for_prime?Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/dustbag/offer.rb', line 36

def eligible_for_prime?
  eligible = offer_listing && offer_listing.locate('IsEligibleForPrime').first
  eligible && eligible.text == '1'
end

#eligible_for_super_saver_shipping?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/dustbag/offer.rb', line 31

def eligible_for_super_saver_shipping?
  eligible = offer_listing && offer_listing.locate('IsEligibleForSuperSaverShipping').first
  eligible && eligible.text == '1'
end

#idObject



11
12
13
14
# File 'lib/dustbag/offer.rb', line 11

def id
  id = offer_listing && offer_listing.locate('OfferListingId').first
  id && id.text
end

#priceObject



16
17
18
19
# File 'lib/dustbag/offer.rb', line 16

def price
  price = offer_listing && offer_listing.locate('Price').first
  Price.parse(price)
end