Class: Elibri::ONIX::Release_3_0::ONIXMessage
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::ONIXMessage
- Defined in:
- lib/elibri_onix/onix_3_0/onix_message.rb
Overview
class representing whole ONIX response from eLibri server
Constant Summary collapse
- ATTRIBUTES =
:nodoc:
[ :release, :elibri_dialect, :header ]
- RELATIONS =
:nodoc:
[ :products ]
Constants included from HashId
HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS
Instance Attribute Summary collapse
-
#elibri_dialect ⇒ Object
:nodoc:.
-
#header ⇒ Object
returned message header - Elibri::ONIX::Release_3_0::Header.
-
#products ⇒ Object
list of all products returned in this mnessage.
-
#release ⇒ Object
ONIX version number.
-
#to_xml ⇒ Object
xml representation of this message.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xml, *initialization_args) ⇒ ONIXMessage
constructor
A new instance of ONIXMessage.
- #inspect_include_fields ⇒ Object
Methods included from HashId
Methods included from Inspector
#attribute_for_inspect, #inspect
Constructor Details
#initialize(xml, *initialization_args) ⇒ ONIXMessage
Returns a new instance of ONIXMessage.
47 48 49 50 51 52 53 54 55 |
# File 'lib/elibri_onix/onix_3_0/onix_message.rb', line 47 def initialize(xml, *initialization_args) @to_xml = xml.to_s xml = Nokogiri::XML(xml) unless xml.is_a?(Nokogiri::XML::Document) = xml.children.first @release = ['release'] @elibri_dialect = .at_xpath('elibri:Dialect').try(:text) @header = Header.new(.at_xpath('xmlns:Header')) if .at_xpath('xmlns:Header') @products = .xpath('xmlns:Product').map { |product_node| Product.new(product_node) } end |
Instance Attribute Details
#elibri_dialect ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/elibri_onix/onix_3_0/onix_message.rb', line 20 def elibri_dialect @elibri_dialect end |
#header ⇒ Object
returned message header - Elibri::ONIX::Release_3_0::Header
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/onix_message.rb', line 23 def header @header end |
#products ⇒ Object
list of all products returned in this mnessage
11 12 13 |
# File 'lib/elibri_onix/onix_3_0/onix_message.rb', line 11 def products @products end |
#release ⇒ Object
ONIX version number
17 18 19 |
# File 'lib/elibri_onix/onix_3_0/onix_message.rb', line 17 def release @release end |
#to_xml ⇒ Object
xml representation of this message
14 15 16 |
# File 'lib/elibri_onix/onix_3_0/onix_message.rb', line 14 def to_xml @to_xml end |
Class Method Details
.from_xml(data, *initialization_args) ⇒ Object
42 43 44 45 |
# File 'lib/elibri_onix/onix_3_0/onix_message.rb', line 42 def self.from_xml(data, *initialization_args) Kernel.warn "[DEPRECATION] `from_xml` is deprecated. Please use `new` instead." self.new(data, *initialization_args) end |
Instance Method Details
#inspect_include_fields ⇒ Object
37 38 39 |
# File 'lib/elibri_onix/onix_3_0/onix_message.rb', line 37 def inspect_include_fields [:header, :elibri_dialect, :release, :products] end |