Class: Elibri::ONIX::Release_3_0::ProductIdentifier

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ProductIdentifier

Returns a new instance of ProductIdentifier.



18
19
20
21
22
23
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 18

def initialize(data)
  @to_xml = data.to_s
  @type = data.at_css('ProductIDType')&.text
  @type_name = data.at_css('IDTypeName')&.text
  @value = data.at_css('IDValue')&.text
end

Instance Attribute Details

#to_xmlObject

xml representation of identifier



16
17
18
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 16

def to_xml
  @to_xml
end

#typeObject

onix code of type (see elibri_onix_dict, Elibri::ONIX::Dict::Release_3_0::ProductIDType)



7
8
9
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 7

def type
  @type
end

#type_nameObject

if type is prioprietery (01) - then the name of type



10
11
12
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 10

def type_name
  @type_name
end

#valueObject

identifier value



13
14
15
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 13

def value
  @value
end

Instance Method Details

#identifier_typeObject

returs the string name of value type



26
27
28
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 26

def identifier_type
  Elibri::ONIX::Dict::Release_3_0::ProductIDType.find_by_onix_code(@type)&.const_name&.downcase
end

#inspect_include_fieldsObject

:nodoc:



31
32
33
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 31

def inspect_include_fields
  [:identifier_type]
end