Class: Elibri::ONIX::Release_3_0::RelatedProduct
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::RelatedProduct
- Defined in:
- lib/elibri_onix/onix_3_0/related_product.rb
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
Constructor Details
#initialize(data) ⇒ RelatedProduct
Returns a new instance of RelatedProduct.
10 11 12 13 14 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 10 def initialize(data) @to_xml = data.to_s @relation_code = data.at_css('ProductRelationCode')&.text @identifiers = data.css('ProductIdentifier').map { |identifier_data| ProductIdentifier.new(identifier_data) } end |
Instance Attribute Details
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
7 8 9 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 7 def identifiers @identifiers end |
#relation_code ⇒ Object (readonly)
Returns the value of attribute relation_code.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 6 def relation_code @relation_code end |
#to_xml ⇒ Object (readonly)
Returns the value of attribute to_xml.
8 9 10 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 8 def to_xml @to_xml end |
Instance Method Details
#proprietary_identifiers ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 22 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
17 18 19 |
# File 'lib/elibri_onix/onix_3_0/related_product.rb', line 17 def record_reference @identifiers.find {|identifier| identifier.type == '01' && identifier.type_name == 'elibri' }&.value end |