Class: Elibri::ONIX::Release_3_0::Collection

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

Constant Summary collapse

ATTRIBUTES =

from ONIX documentation: A bibliographic collection in ONIX 3.0 means a fixed or indefinite number of products, published over a fixed or indefinite time period, which share collective attributes (including a collective title) that are required as part of the bibliographic record of each individual product. In this respect, such a collection is most often thought of as a series. A bibliographic collection may, however, also be traded as a single product (often thought of as a set), but this does not alter the way in which its collective attributes are described in the ONIX records for the individual products. set. If a fixed or indefinite number of products have a collective title and possibly other collective attributes that are required as part of the bibliographic record of each individual product, then those products are regarded as forming a collection. ONIX 3.0 recognises two major types of collection: a publisher collection, and an ascribed collection. A publisher collection is one that is identified either on the products themselves or in product information originating from the publisher. An ascribed collection is one that is identified by another party in the information supply chain, usually an aggregator, for the benefit of retailers and consumers.

[
  :type, :title_detail, :full_title, :type_name
]
RELATIONS =
[
  :elements, :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) ⇒ Collection

Returns a new instance of Collection.



35
36
37
38
39
40
# File 'lib/elibri_onix/onix_3_0/collection.rb', line 35

def initialize(data)
  @to_xml = data.to_s
  @type = data.at_xpath('xmlns:CollectionType').try(:text)
  @elements = data.xpath('xmlns:TitleElement').map { |element_data| TitleElement.new(element_data) }
  @title_detail = TitleDetail.new(data.at_xpath('xmlns:TitleDetail')) if data.at_xpath('xmlns:TitleDetail')
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



33
34
35
# File 'lib/elibri_onix/onix_3_0/collection.rb', line 33

def elements
  @elements
end

#title_detailObject

Returns the value of attribute title_detail.



33
34
35
# File 'lib/elibri_onix/onix_3_0/collection.rb', line 33

def title_detail
  @title_detail
end

#to_xmlObject

Returns the value of attribute to_xml.



33
34
35
# File 'lib/elibri_onix/onix_3_0/collection.rb', line 33

def to_xml
  @to_xml
end

#typeObject

Returns the value of attribute type.



33
34
35
# File 'lib/elibri_onix/onix_3_0/collection.rb', line 33

def type
  @type
end

Instance Method Details

#full_titleObject



42
43
44
# File 'lib/elibri_onix/onix_3_0/collection.rb', line 42

def full_title
  title_detail.try(:full_title)
end

#inspect_include_fieldsObject



50
51
52
# File 'lib/elibri_onix/onix_3_0/collection.rb', line 50

def inspect_include_fields
  [:type_name]
end

#type_nameObject



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

def type_name
  Elibri::ONIX::Dict::Release_3_0::CollectionType.find_by_onix_code(@type).const_name.downcase
end