Class: Elibri::ONIX::Release_3_0::Supplier
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::Supplier
- Includes:
- HashId
- Defined in:
- lib/elibri_onix/onix_3_0/supplier.rb
Constant Summary collapse
- ATTRIBUTES =
from ONIX documentation: A group of data elements which together define a supplier. Mandatory in each occurrence of the <SupplyDetail> composite, and not repeatable.
[ :role, :name, :telephone_number, :email_address, :website, :nip ]
- RELATIONS =
[ :identifiers ]
Constants included from HashId
HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS
Instance Attribute Summary collapse
-
#email_address ⇒ Object
Returns the value of attribute email_address.
-
#identifiers ⇒ Object
Returns the value of attribute identifiers.
-
#name ⇒ Object
Returns the value of attribute name.
-
#role ⇒ Object
Returns the value of attribute role.
-
#telephone_number ⇒ Object
Returns the value of attribute telephone_number.
-
#to_xml ⇒ Object
Returns the value of attribute to_xml.
-
#website ⇒ Object
Returns the value of attribute website.
Instance Method Summary collapse
-
#initialize(data) ⇒ Supplier
constructor
A new instance of Supplier.
- #nip ⇒ Object
Methods included from HashId
Constructor Details
#initialize(data) ⇒ Supplier
Returns a new instance of Supplier.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 25 def initialize(data) @to_xml = data.to_s @role = data.at_xpath('xmlns:SupplierRole').try(:text).try(:to_i) @identifiers = data.xpath('xmlns:SupplierIdentifier').map { |identifier_data| SupplierIdentifier.new(identifier_data) } @name = data.at_xpath('xmlns:SupplierName').try(:text) @telephone_number = data.at_xpath('xmlns:TelephoneNumber').try(:text) @email_address = data.at_xpath('xmlns:EmailAddress').try(:text) if data.at_xpath('xmlns:Website') @website = data.at_xpath('xmlns:Website').at_xpath('xmlns:WebsiteLink').try(:text) end end |
Instance Attribute Details
#email_address ⇒ Object
Returns the value of attribute email_address.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 23 def email_address @email_address end |
#identifiers ⇒ Object
Returns the value of attribute identifiers.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 23 def identifiers @identifiers end |
#name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 23 def name @name end |
#role ⇒ Object
Returns the value of attribute role.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 23 def role @role end |
#telephone_number ⇒ Object
Returns the value of attribute telephone_number.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 23 def telephone_number @telephone_number end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 23 def to_xml @to_xml end |
#website ⇒ Object
Returns the value of attribute website.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 23 def website @website end |
Instance Method Details
#nip ⇒ Object
37 38 39 |
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 37 def nip @identifiers.find {|identifier| (identifier.type == '02') && (identifier.type_name == 'NIP')}.try(:value) end |