Class: Elibri::ONIX::Release_3_0::Supplier

Inherits:
Object
  • Object
show all
Defined in:
lib/elibri_onix/onix_3_0/supplier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Supplier

Returns a new instance of Supplier.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 8

def initialize(data)
  @to_xml = data.to_s
  @role = data.at_css('SupplierRole')&.text
  @identifiers = data.css('SupplierIdentifier').map { |identifier_data| SupplierIdentifier.new(identifier_data) }
  @name = data.at_css('SupplierName')&.text
  @telephone_number = data.at_css('TelephoneNumber')&.text
  @email_address = data.at_css('EmailAddress')&.text
  if data.at_css('Website')
    @website = data.at_css('Website').at_css('WebsiteLink')&.text
  end
end

Instance Attribute Details

#email_addressObject

Returns the value of attribute email_address.



6
7
8
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 6

def email_address
  @email_address
end

#identifiersObject

Returns the value of attribute identifiers.



6
7
8
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 6

def identifiers
  @identifiers
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 6

def name
  @name
end

#roleObject

Returns the value of attribute role.



6
7
8
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 6

def role
  @role
end

#telephone_numberObject

Returns the value of attribute telephone_number.



6
7
8
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 6

def telephone_number
  @telephone_number
end

#to_xmlObject

Returns the value of attribute to_xml.



6
7
8
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 6

def to_xml
  @to_xml
end

#websiteObject

Returns the value of attribute website.



6
7
8
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 6

def website
  @website
end

Instance Method Details

#nipObject



20
21
22
# File 'lib/elibri_onix/onix_3_0/supplier.rb', line 20

def nip
  @identifiers.find {|identifier| (identifier.type == '02') && (identifier.type_name == 'NIP')}&.value
end