Class: Elibri::ONIX::Release_3_0::RelatedProduct
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::RelatedProduct
- Includes:
- HashId
- Defined in:
- lib/elibri_onix/onix_3_0/related_product.rb
Constant Summary collapse
- ATTRIBUTES =
:nodoc:
[ :relation_code, :proprietary_identifiers, :record_reference ]
- RELATIONS =
:nodoc:
[ :identifiers ]
Constants included from HashId
HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS
Instance Attribute Summary collapse
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
-
#relation_code ⇒ Object
readonly
Returns the value of attribute relation_code.
-
#to_xml ⇒ Object
readonly
Returns the value of attribute to_xml.
Instance Method Summary collapse
-
#initialize(data) ⇒ RelatedProduct
constructor
A new instance of RelatedProduct.
- #proprietary_identifiers ⇒ Object
- #record_reference ⇒ Object
Methods included from HashId
Constructor Details
#initialize(data) ⇒ RelatedProduct
Returns a new instance of RelatedProduct.
28 29 30 31 32 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 28 def initialize(data) @to_xml = data.to_s @relation_code = data.at_xpath('xmlns:ProductRelationCode').try(:text) @identifiers = data.xpath('xmlns:ProductIdentifier').map { |identifier_data| ProductIdentifier.new(identifier_data) } end |
Instance Attribute Details
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
25 26 27 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 25 def identifiers @identifiers end |
#relation_code ⇒ Object (readonly)
Returns the value of attribute relation_code.
24 25 26 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 24 def relation_code @relation_code end |
#to_xml ⇒ Object (readonly)
Returns the value of attribute to_xml.
26 27 28 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 26 def to_xml @to_xml end |
Instance Method Details
#proprietary_identifiers ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 40 def proprietary_identifiers Hash.new.tap do |hash| @identifiers.each do |identifier| hash[identifier.type_name] = identifier.value if identifier.type == '01' end end end |
#record_reference ⇒ Object
35 36 37 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 35 def record_reference @identifiers.find {|identifier| identifier.type == '01' && identifier.type_name == 'elibri' }.try(:value) end |