/
collection.rb
46 lines (34 loc) · 2.29 KB
/
collection.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Elibri
module ONIX
module Release_3_0
class Collection
#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.
ATTRIBUTES = [
:type, :title_detail, :full_title, :type_name
]
RELATIONS = [
:elements, :inspect_include_fields
]
attr_accessor :type, :elements, :title_detail, :to_xml
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
def full_title
title_detail.try(:full_title)
end
def type_name
Elibri::ONIX::Dict::Release_3_0::CollectionType.find_by_onix_code(@type).const_name.downcase
end
def inspect_include_fields
[:type_name]
end
end
end
end
end