Class: Elibri::ONIX::Release_3_0::SupplyDetail

Inherits:
Object
  • Object
show all
Includes:
HashId
Defined in:
lib/elibri_onix/onix_3_0/supply_detail.rb

Constant Summary collapse

ATTRIBUTES =
[
  :relation_code, :supplier, :product_availability, :pack_quantity, :price, :on_hand, :quantity_coded, :quantity_code
]
RELATIONS =
[]

Constants included from HashId

HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashId

#calculate_hash, #eid

Constructor Details

#initialize(data) ⇒ SupplyDetail

Returns a new instance of SupplyDetail.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 25

def initialize(data)
  @to_xml = data.to_s
  @relation_code = data.at_xpath('xmlns:ProductRelationCode').try(:text).try(:to_i)
  @supplier = Supplier.new(data.at_xpath('xmlns:Supplier')) if data.at_xpath('xmlns:Supplier')
  @product_availability = data.at_xpath('xmlns:ProductAvailability').try(:text).try(:to_i)
  @pack_quantity = data.at_xpath('xmlns:PackQuantity').try(:text).try(:to_i)
  @price = Price.new(data.at_xpath('xmlns:Price')) if data.at_xpath('xmlns:Price')
  if data.at_xpath('xmlns:Stock')
    @on_hand = data.at_xpath('xmlns:Stock').at_xpath('xmlns:OnHand').try(:text).try(:to_i)
    @quantity_coded = StockQuantityCoded.new(data.at_xpath('xmlns:Stock').at_xpath('xmlns:StockQuantityCoded')) if data.at_xpath('xmlns:Stock').at_xpath('xmlns:StockQuantityCoded')
  end
end

Instance Attribute Details

#on_handObject

Returns the value of attribute on_hand.



21
22
23
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 21

def on_hand
  @on_hand
end

#pack_quantityObject

Returns the value of attribute pack_quantity.



21
22
23
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 21

def pack_quantity
  @pack_quantity
end

#priceObject

Returns the value of attribute price.



21
22
23
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 21

def price
  @price
end

#product_availabilityObject

Returns the value of attribute product_availability.



21
22
23
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 21

def product_availability
  @product_availability
end

#quantity_codedObject

Returns the value of attribute quantity_coded.



21
22
23
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 21

def quantity_coded
  @quantity_coded
end

#relation_codeObject

Returns the value of attribute relation_code.



21
22
23
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 21

def relation_code
  @relation_code
end

#supplierObject

Returns the value of attribute supplier.



21
22
23
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 21

def supplier
  @supplier
end

#to_xmlObject

Returns the value of attribute to_xml.



21
22
23
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 21

def to_xml
  @to_xml
end

Instance Method Details

#quantity_codeObject



38
39
40
# File 'lib/elibri_onix/onix_3_0/supply_detail.rb', line 38

def quantity_code
  @quantity_coded.try(:code)
end