Class: Mws::Apis::Feeds::PriceListing
- Inherits:
-
Object
- Object
- Mws::Apis::Feeds::PriceListing
- Defined in:
- lib/mws/apis/feeds/price_listing.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#sale ⇒ Object
readonly
Returns the value of attribute sale.
-
#sku ⇒ Object
readonly
Returns the value of attribute sku.
Instance Method Summary collapse
-
#initialize(sku, base, options = {}) ⇒ PriceListing
constructor
A new instance of PriceListing.
- #on_sale(amount, from, to) ⇒ Object
- #to_xml(name = 'Price', parent = nil) ⇒ Object
Constructor Details
#initialize(sku, base, options = {}) ⇒ PriceListing
Returns a new instance of PriceListing.
9 10 11 12 13 14 15 16 |
# File 'lib/mws/apis/feeds/price_listing.rb', line 9 def initialize(sku, base, ={}) @sku = sku @base = Money.new(base, [:currency]) @currency = @base.currency @min = Money.new([:min], @currency) if .include? :min on_sale([:sale][:amount], [:sale][:from], [:sale][:to]) if .include? :sale validate end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
7 8 9 |
# File 'lib/mws/apis/feeds/price_listing.rb', line 7 def base @base end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
7 8 9 |
# File 'lib/mws/apis/feeds/price_listing.rb', line 7 def currency @currency end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
7 8 9 |
# File 'lib/mws/apis/feeds/price_listing.rb', line 7 def min @min end |
#sale ⇒ Object (readonly)
Returns the value of attribute sale.
7 8 9 |
# File 'lib/mws/apis/feeds/price_listing.rb', line 7 def sale @sale end |
#sku ⇒ Object (readonly)
Returns the value of attribute sku.
7 8 9 |
# File 'lib/mws/apis/feeds/price_listing.rb', line 7 def sku @sku end |
Instance Method Details
#on_sale(amount, from, to) ⇒ Object
18 19 20 21 22 |
# File 'lib/mws/apis/feeds/price_listing.rb', line 18 def on_sale(amount, from, to) @sale = SalePrice.new Money.new(amount, @currency), from, to validate self end |
#to_xml(name = 'Price', parent = nil) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/mws/apis/feeds/price_listing.rb', line 24 def to_xml(name='Price', parent=nil) Mws::Serializer.tree name, parent do |xml| xml.SKU @sku @base.to_xml 'StandardPrice', xml @min.to_xml 'MAP', xml if @min @sale.to_xml 'Sale', xml if @sale end end |