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

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

Overview

product identifier, for example isbn

Constant Summary collapse

ATTRIBUTES =

:nodoc:

[
  :type, :type_name, :value, :identifier_type
]
RELATIONS =

:nodoc:

[
  :inspect_include_fields
]

Constants included from HashId

HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashId

#calculate_hash, #eid

Constructor Details

#initialize(data) ⇒ ProductIdentifier

Returns a new instance of ProductIdentifier.



33
34
35
36
37
38
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 33

def initialize(data)
  @to_xml = data.to_s
  @type = data.at_xpath('xmlns:ProductIDType').try(:text)
  @type_name = data.at_xpath('xmlns:IDTypeName').try(:text)
  @value = data.at_xpath('xmlns:IDValue').try(:text)
end

Instance Attribute Details

#to_xmlObject

xml representation of identifier



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

def to_xml
  @to_xml
end

#typeObject

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



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

def type
  @type
end

#type_nameObject

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



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

def type_name
  @type_name
end

#valueObject

identifier value



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

def value
  @value
end

Instance Method Details

#identifier_typeObject

returs the string name of value type



41
42
43
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 41

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

#inspect_include_fieldsObject

:nodoc:



46
47
48
# File 'lib/elibri_onix/onix_3_0/product_identifier.rb', line 46

def inspect_include_fields
  [:identifier_type]
end