Class: Elibri::ONIX::Release_3_0::Product

Inherits:
Object
  • Object
show all
Includes:
Inspector
Defined in:
lib/elibri_onix/onix_3_0/product.rb

Overview

Klasa reprezentująca produkt Niektóre pola mogą pozostać bez wartości - zależy to od formy produktu

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspector

#attribute_for_inspect, #inspect

Constructor Details

#initialize(data) ⇒ Product

:doc:



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/elibri_onix/onix_3_0/product.rb', line 217

def initialize(data)
  @to_xml = data.to_s
  #initialize variables that need to be array
  ##descriptive_details
  @text_contents = []
  @supporting_resources = []
  ##collateral_details
  @measures = []
  @title_details = []
  @collections = []
  @contributors = []
  @languages = []
  @extents = []
  @thema_subjects = []
  @publisher_subjects = []
  @audience_ranges = []
  ##publishing_details
  @sales_restrictions = []
  @excerpt_infos = []
  #moving to parsing attributes

  @record_reference = data.at_css('RecordReference')&.text
  @notification_type = data.at_css('NotificationType')&.text
  @deletion_text = data.at_css('DeletionText')&.text

  @identifiers = data.children.find_all { |node| node.name == 'ProductIdentifier' }.map { |ident_data| ProductIdentifier.new(ident_data) }
  begin
    @related_products = data.at_css('RelatedMaterial').css('RelatedProduct').map { |related_data| RelatedProduct.new(related_data) }
  rescue
    @related_products = []
  end
  @supply_details = data.css('SupplyDetail').map { |supply_data| SupplyDetail.new(supply_data) }

  #00 - Supplier role - Unspecified
  price_sd = @supply_details.find { |sd| sd.supplier && ["00", Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_TO_RET].include?(sd.supplier.role) }
  if price_sd && price_sd.prices[0] && price_sd.prices[0].type == Elibri::ONIX::Dict::Release_3_0::PriceTypeCode::RRP_WITH_TAX
    @vat = price_sd.prices[0].tax_rate_percent.to_i
    @cover_price = price_sd.prices[0].amount
    @additional_trade_information = price_sd.additional_trade_information
  end

  descriptive_details_setup(data.at_css('DescriptiveDetail')) if data.at_css('DescriptiveDetail')
  collateral_details_setup(data.at_css('CollateralDetail')) if data.at_css('CollateralDetail')

  @preview_exists = !!@supporting_resources.find { |sr| sr.content_type_name == "widget" && sr.link =~ /p.elibri.com.pl/ }

  product_form_features_setup(data.css("ProductFormFeature"))

  publishing_details_setup(data.at_css('PublishingDetail')) if data.at_css('PublishingDetail')
  licence_information_setup(data)
 demo = @supporting_resources.find { |sr| sr.content_type_name == "sample_content" }
  if demo
    @excerpt_infos = demo.data.css("ResourceVersion").map { |node| ExcerptInfo.new(node) }
  end

  @file_infos = data.css("BodyResource").map { |node| FileInfo.new(node) }
  after_parse
end

Instance Attribute Details

#additional_infoObject (readonly)

AdditionalInfo



121
122
123
# File 'lib/elibri_onix/onix_3_0/product.rb', line 121

def additional_info
  @additional_info
end

#additional_trade_informationObject (readonly)

dodatkowa informacja handlowa



162
163
164
# File 'lib/elibri_onix/onix_3_0/product.rb', line 162

def additional_trade_information
  @additional_trade_information
end

#audience_rangesObject (readonly)

Returns the value of attribute audience_ranges.



204
205
206
# File 'lib/elibri_onix/onix_3_0/product.rb', line 204

def audience_ranges
  @audience_ranges
end

#city_of_publicationObject (readonly)

miasto, w którym została wydana ksiażka



150
151
152
# File 'lib/elibri_onix/onix_3_0/product.rb', line 150

def city_of_publication
  @city_of_publication
end

#cn_codeObject (readonly)

cn code



180
181
182
# File 'lib/elibri_onix/onix_3_0/product.rb', line 180

def cn_code
  @cn_code
end

#collection_partObject (readonly)

numer w cyklu



78
79
80
# File 'lib/elibri_onix/onix_3_0/product.rb', line 78

def collection_part
  @collection_part
end

#collection_titleObject (readonly)

nazwa cyklu (częste przy komiksach, gdy seria jest częścią tytułu, np. Thorgal)



75
76
77
# File 'lib/elibri_onix/onix_3_0/product.rb', line 75

def collection_title
  @collection_title
end

#collectionsObject (readonly)

Returns the value of attribute collections.



200
201
202
# File 'lib/elibri_onix/onix_3_0/product.rb', line 200

def collections
  @collections
end

#contributorsObject (readonly)

lista autorów, tłumaczy i innych, którzy mieli wkład w książkę, lista instancji Contributor



132
133
134
# File 'lib/elibri_onix/onix_3_0/product.rb', line 132

def contributors
  @contributors
end

#country_of_manufactureObject (readonly)

kraj produkcji



183
184
185
# File 'lib/elibri_onix/onix_3_0/product.rb', line 183

def country_of_manufacture
  @country_of_manufacture
end

#cover_priceObject (readonly)

sugerowana cena detaliczna brutto produktu



109
110
111
# File 'lib/elibri_onix/onix_3_0/product.rb', line 109

def cover_price
  @cover_price
end

#cover_typeObject (readonly)

typ okładki, np. ‘miękka ze skrzydełkami’



106
107
108
# File 'lib/elibri_onix/onix_3_0/product.rb', line 106

def cover_type
  @cover_type
end

#current_stateObject (readonly)

Status produktu - jedna z wartości: announced, :preorder, :published, :out_of_print, :deleted, :indefinitely_postponed, cancelled



51
52
53
# File 'lib/elibri_onix/onix_3_0/product.rb', line 51

def current_state
  @current_state
end

#deletion_textObject (readonly)

Returns the value of attribute deletion_text.



193
194
195
# File 'lib/elibri_onix/onix_3_0/product.rb', line 193

def deletion_text
  @deletion_text
end

#descriptionObject (readonly)

Opis produktu, instancja TextContent



63
64
65
# File 'lib/elibri_onix/onix_3_0/product.rb', line 63

def description
  @description
end

#digital_formatsObject (readonly)

lista formatów, w jakich jest dostępny ebook (PDF, MOBI, EPUB)



96
97
98
# File 'lib/elibri_onix/onix_3_0/product.rb', line 96

def digital_formats
  @digital_formats
end

#durationObject (readonly)

czas trwania nagrania w audiobooku, w minutach



38
39
40
# File 'lib/elibri_onix/onix_3_0/product.rb', line 38

def duration
  @duration
end

#eanObject (readonly)

ean, jeśli jest inny, niż isbn13



29
30
31
# File 'lib/elibri_onix/onix_3_0/product.rb', line 29

def ean
  @ean
end

#edition_statementObject (readonly)

informacja o numerze wydania



138
139
140
# File 'lib/elibri_onix/onix_3_0/product.rb', line 138

def edition_statement
  @edition_statement
end

#edition_type_onix_codeObject (readonly)

informacja o type wydanie, kod onix



141
142
143
# File 'lib/elibri_onix/onix_3_0/product.rb', line 141

def edition_type_onix_code
  @edition_type_onix_code
end

#excerpt_infosObject (readonly)

informacje o fragmentach utworów (produkty cyfrowe)



153
154
155
# File 'lib/elibri_onix/onix_3_0/product.rb', line 153

def excerpt_infos
  @excerpt_infos
end

#excerptsObject (readonly)

Returns the value of attribute excerpts.



190
191
192
# File 'lib/elibri_onix/onix_3_0/product.rb', line 190

def excerpts
  @excerpts
end

#extentsObject (readonly)

Returns the value of attribute extents.



201
202
203
# File 'lib/elibri_onix/onix_3_0/product.rb', line 201

def extents
  @extents
end

#file_infosObject (readonly)

informacje o plikach master (produkty cyfrowe)



156
157
158
# File 'lib/elibri_onix/onix_3_0/product.rb', line 156

def file_infos
  @file_infos
end

#file_sizeObject (readonly)

Returns the value of attribute file_size.



188
189
190
# File 'lib/elibri_onix/onix_3_0/product.rb', line 188

def file_size
  @file_size
end

#full_titleObject (readonly)

pełen tytuł



81
82
83
# File 'lib/elibri_onix/onix_3_0/product.rb', line 81

def full_title
  @full_title
end

#heightObject (readonly)

:doc: wysokość w milimetrach



17
18
19
# File 'lib/elibri_onix/onix_3_0/product.rb', line 17

def height
  @height
end

#hyphenated_isbnObject (readonly)

isbn z kreskami



159
160
161
# File 'lib/elibri_onix/onix_3_0/product.rb', line 159

def hyphenated_isbn
  @hyphenated_isbn
end

#identifiersObject (readonly)

Returns the value of attribute identifiers.



206
207
208
# File 'lib/elibri_onix/onix_3_0/product.rb', line 206

def identifiers
  @identifiers
end

#imprintObject (readonly)

Returns the value of attribute imprint.



196
197
198
# File 'lib/elibri_onix/onix_3_0/product.rb', line 196

def imprint
  @imprint
end

#imprint_nameObject (readonly)

Imprint, jeśli wydawnictwo używa imprintów. Jeżeli wydawnictwo podało imprint, to ta wartość powinna zostać wyświetlona użytkownikowi w sklepie jako nazwa wydawnictwa.



48
49
50
# File 'lib/elibri_onix/onix_3_0/product.rb', line 48

def imprint_name
  @imprint_name
end

#isbn13Object (readonly)

isbn13 - bez kresek



32
33
34
# File 'lib/elibri_onix/onix_3_0/product.rb', line 32

def isbn13
  @isbn13
end

#languagesObject (readonly)

lista języków, lista intancji Language



135
136
137
# File 'lib/elibri_onix/onix_3_0/product.rb', line 135

def languages
  @languages
end

#licence_limited_toObject (readonly)

data końca licencji, jeśli licencja nie jest bezterminowa, instancja Date



93
94
95
# File 'lib/elibri_onix/onix_3_0/product.rb', line 93

def licence_limited_to
  @licence_limited_to
end

#licence_limited_to_before_type_castObject (readonly)

data końca licencji, jeśli licencja nie jest bezterminowa, w formacie YYYYMMDD



90
91
92
# File 'lib/elibri_onix/onix_3_0/product.rb', line 90

def licence_limited_to_before_type_cast
  @licence_limited_to_before_type_cast
end

#measuresObject (readonly)

Returns the value of attribute measures.



195
196
197
# File 'lib/elibri_onix/onix_3_0/product.rb', line 195

def measures
  @measures
end

#no_contributorObject

:nodoc:



214
215
216
# File 'lib/elibri_onix/onix_3_0/product.rb', line 214

def no_contributor
  @no_contributor
end

#notification_typeObject (readonly)

Returns the value of attribute notification_type.



192
193
194
# File 'lib/elibri_onix/onix_3_0/product.rb', line 192

def notification_type
  @notification_type
end

#number_of_illustrationsObject (readonly)

liczba ilustracji



144
145
146
# File 'lib/elibri_onix/onix_3_0/product.rb', line 144

def number_of_illustrations
  @number_of_illustrations
end

#number_of_pagesObject (readonly)

ilość stron w książce drukowanej



35
36
37
# File 'lib/elibri_onix/onix_3_0/product.rb', line 35

def number_of_pages
  @number_of_pages
end

#number_of_piecesObject (readonly)

ilość elementów (puzzle, gry planszowe)



165
166
167
# File 'lib/elibri_onix/onix_3_0/product.rb', line 165

def number_of_pieces
  @number_of_pieces
end

#original_titleObject (readonly)

tytuł oryginału



84
85
86
# File 'lib/elibri_onix/onix_3_0/product.rb', line 84

def original_title
  @original_title
end

#pdw_exclusivenessObject (readonly)

PDWExclusiveness



118
119
120
# File 'lib/elibri_onix/onix_3_0/product.rb', line 118

def pdw_exclusiveness
  @pdw_exclusiveness
end

#pkwiuObject (readonly)

PKWiU



115
116
117
# File 'lib/elibri_onix/onix_3_0/product.rb', line 115

def pkwiu
  @pkwiu
end

#players_number_fromObject (readonly)

min. ilość graczy - gry planszowe



168
169
170
# File 'lib/elibri_onix/onix_3_0/product.rb', line 168

def players_number_from
  @players_number_from
end

#players_number_toObject (readonly)

max. ilość graczy - gry planszowe



171
172
173
# File 'lib/elibri_onix/onix_3_0/product.rb', line 171

def players_number_to
  @players_number_to
end

#playing_time_fromObject (readonly)

min. czas gry - gry planszowe



174
175
176
# File 'lib/elibri_onix/onix_3_0/product.rb', line 174

def playing_time_from
  @playing_time_from
end

#playing_time_toObject (readonly)

max. czas gry - gry planszowe



177
178
179
# File 'lib/elibri_onix/onix_3_0/product.rb', line 177

def playing_time_to
  @playing_time_to
end

#preorder_embargo_dateObject (readonly)

Returns the value of attribute preorder_embargo_date.



211
212
213
# File 'lib/elibri_onix/onix_3_0/product.rb', line 211

def preorder_embargo_date
  @preorder_embargo_date
end

#preview_existsObject

:nodoc:



214
215
216
# File 'lib/elibri_onix/onix_3_0/product.rb', line 214

def preview_exists
  @preview_exists
end

#product_compositionObject (readonly)

Returns the value of attribute product_composition.



194
195
196
# File 'lib/elibri_onix/onix_3_0/product.rb', line 194

def product_composition
  @product_composition
end

#product_formObject (readonly)



125
126
127
# File 'lib/elibri_onix/onix_3_0/product.rb', line 125

def product_form
  @product_form
end

#product_form_nameObject (readonly)

nazwa typu produktu, małe litery, np. ‘book’ - patrz pełna lista pod adresem github.com/elibri/elibri_onix_dict/blob/master/lib/elibri_onix_dict/onix_3_0/serialized/ProductFormCode.yml



129
130
131
# File 'lib/elibri_onix/onix_3_0/product.rb', line 129

def product_form_name
  @product_form_name
end

#publisherObject (readonly)

Returns the value of attribute publisher.



197
198
199
# File 'lib/elibri_onix/onix_3_0/product.rb', line 197

def publisher
  @publisher
end

#publisher_idObject (readonly)

ID wydawnictwa w systemie elibri



44
45
46
# File 'lib/elibri_onix/onix_3_0/product.rb', line 44

def publisher_id
  @publisher_id
end

#publisher_nameObject (readonly)

nazwa wydawnictwa



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

def publisher_name
  @publisher_name
end

#publisher_subjectsObject (readonly)

Returns the value of attribute publisher_subjects.



203
204
205
# File 'lib/elibri_onix/onix_3_0/product.rb', line 203

def publisher_subjects
  @publisher_subjects
end

#publishing_dateObject (readonly)

Returns the value of attribute publishing_date.



209
210
211
# File 'lib/elibri_onix/onix_3_0/product.rb', line 209

def publishing_date
  @publishing_date
end

#publishing_statusObject (readonly)

Returns the value of attribute publishing_status.



198
199
200
# File 'lib/elibri_onix/onix_3_0/product.rb', line 198

def publishing_status
  @publishing_status
end

#reading_age_fromObject (readonly)

Wiek czytelnika - od



54
55
56
# File 'lib/elibri_onix/onix_3_0/product.rb', line 54

def reading_age_from
  @reading_age_from
end

#reading_age_toObject (readonly)

Wiek czytelnika - do



57
58
59
# File 'lib/elibri_onix/onix_3_0/product.rb', line 57

def reading_age_to
  @reading_age_to
end

#record_referenceObject (readonly)

record reference - wewnętrzny identyfikator rekordu, niezmienny i unikatowy



103
104
105
# File 'lib/elibri_onix/onix_3_0/product.rb', line 103

def record_reference
  @record_reference
end

Returns the value of attribute related_products.



210
211
212
# File 'lib/elibri_onix/onix_3_0/product.rb', line 210

def related_products
  @related_products
end

#reviewsObject (readonly)

Returns the value of attribute reviews.



189
190
191
# File 'lib/elibri_onix/onix_3_0/product.rb', line 189

def reviews
  @reviews
end

#sale_restricted_to_polandObject

:nodoc:



214
215
216
# File 'lib/elibri_onix/onix_3_0/product.rb', line 214

def sale_restricted_to_poland
  @sale_restricted_to_poland
end

#sales_restrictionsObject (readonly)

Returns the value of attribute sales_restrictions.



208
209
210
# File 'lib/elibri_onix/onix_3_0/product.rb', line 208

def sales_restrictions
  @sales_restrictions
end

#seriesObject (readonly)

lista serii, w postaci [nazwa serii, numer w serii]



66
67
68
# File 'lib/elibri_onix/onix_3_0/product.rb', line 66

def series
  @series
end

#short_descriptionObject (readonly)

krótki opis, jeśli wydawca takowy zamieści, instancja TextContent



87
88
89
# File 'lib/elibri_onix/onix_3_0/product.rb', line 87

def short_description
  @short_description
end

#subtitleObject (readonly)

podtytuł



72
73
74
# File 'lib/elibri_onix/onix_3_0/product.rb', line 72

def subtitle
  @subtitle
end

#supply_detailsObject (readonly)

Returns the value of attribute supply_details.



205
206
207
# File 'lib/elibri_onix/onix_3_0/product.rb', line 205

def supply_details
  @supply_details
end

#supporting_resourcesObject (readonly)

Returns the value of attribute supporting_resources.



207
208
209
# File 'lib/elibri_onix/onix_3_0/product.rb', line 207

def supporting_resources
  @supporting_resources
end

#table_of_contentsObject (readonly)

Spis treści - jeśli wydawca takowy umieścił, instancja TextContent



60
61
62
# File 'lib/elibri_onix/onix_3_0/product.rb', line 60

def table_of_contents
  @table_of_contents
end

#technical_protectionObject (readonly)

sposób zabezpieczania pliki (DRM, WATERMARK) - pliki dostępne w API transakcyjnym zawsze będą chronione watermarkiem



99
100
101
# File 'lib/elibri_onix/onix_3_0/product.rb', line 99

def technical_protection
  @technical_protection
end

#technical_protection_onix_codeObject (readonly)

Returns the value of attribute technical_protection_onix_code.



100
101
102
# File 'lib/elibri_onix/onix_3_0/product.rb', line 100

def technical_protection_onix_code
  @technical_protection_onix_code
end

#text_contentsObject (readonly)

:nodoc:



187
188
189
# File 'lib/elibri_onix/onix_3_0/product.rb', line 187

def text_contents
  @text_contents
end

#thema_subjectsObject (readonly)

Returns the value of attribute thema_subjects.



202
203
204
# File 'lib/elibri_onix/onix_3_0/product.rb', line 202

def thema_subjects
  @thema_subjects
end

#thicknessObject (readonly)

gruboś w milimetrach



23
24
25
# File 'lib/elibri_onix/onix_3_0/product.rb', line 23

def thickness
  @thickness
end

#titleObject (readonly)

tytuł ksiażki



69
70
71
# File 'lib/elibri_onix/onix_3_0/product.rb', line 69

def title
  @title
end

#title_detailsObject (readonly)

Returns the value of attribute title_details.



199
200
201
# File 'lib/elibri_onix/onix_3_0/product.rb', line 199

def title_details
  @title_details
end

#to_xmlObject (readonly)

reprezentacja xml dla produktu



147
148
149
# File 'lib/elibri_onix/onix_3_0/product.rb', line 147

def to_xml
  @to_xml
end

#trade_titleObject (readonly)

Returns the value of attribute trade_title.



191
192
193
# File 'lib/elibri_onix/onix_3_0/product.rb', line 191

def trade_title
  @trade_title
end

#unlimited_licenceObject

:nodoc:



214
215
216
# File 'lib/elibri_onix/onix_3_0/product.rb', line 214

def unlimited_licence
  @unlimited_licence
end

#vatObject (readonly)

stawka VAT



112
113
114
# File 'lib/elibri_onix/onix_3_0/product.rb', line 112

def vat
  @vat
end

#weightObject (readonly)

waga w gramach



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

def weight
  @weight
end

#widthObject (readonly)

szerokość w milimetrach



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

def width
  @width
end

Instance Method Details

#authorsObject



429
430
431
# File 'lib/elibri_onix/onix_3_0/product.rb', line 429

def authors
  unnamed_persons? ? ["praca zbiorowa"] : @contributors.find_all { |c| c.role_name == "author" }.map(&:person_name)
end

#collateral_details_setup(data) ⇒ Object



368
369
370
371
# File 'lib/elibri_onix/onix_3_0/product.rb', line 368

def collateral_details_setup(data)
  @text_contents = data.css('TextContent').map { |text_detail| TextContent.new(text_detail) }
  @supporting_resources = data.css('SupportingResource').map { |supporting_data| SupportingResource.new(supporting_data) }
end

#descriptive_details_setup(data) ⇒ Object



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/elibri_onix/onix_3_0/product.rb', line 311

def descriptive_details_setup(data)
  @country_of_manufacture = data.at_css("CountryOfManufacture")&.text

  @product_composition = data.at_css('ProductComposition')&.text
  @product_form = data.at_css('ProductForm')&.text
  if @product_form
    if Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(@product_form)
      @product_form_name = Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(@product_form).name(:en).downcase
    end

    simplified_product_form = @product_form =~ /^B/ ? "BA" : @product_form
    if Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(simplified_product_form)&.digital?
      @digital_formats = []
      data.css("ProductFormDetail").each do |format|
        format_name = Elibri::ONIX::Dict::Release_3_0::ProductFormDetail::find_by_onix_code(format.text)&.name
        @digital_formats << format_name.upcase.gsub("MOBIPOCKET", "MOBI") if format_name
      end
    end

  end
  data.css('ProductClassification').each do |cl|
    cl_type = cl.at_css('ProductClassificationType').text
    cl_value = cl.at_css('ProductClassificationCode').text
    if cl_type == Elibri::ONIX::Dict::Release_3_0::ProductClassificationType::PKWIU
      @pkwiu = cl_value
    elsif cl_type == Elibri::ONIX::Dict::Release_3_0::ProductClassificationType::CN
      @cn_code = cl_value
    end
  end
  @measures =  data.css('Measure').map { |measure_data| Measure.new(measure_data) }
  @title_details = data.children.find_all { |node| node.name == 'TitleDetail' }.map { |title_data| TitleDetail.new(title_data) }
  @collections = data.css('Collection').map { |collection_data| Collection.new(collection_data) }
  @contributors = data.css('Contributor').map { |contributor_data| Contributor.new(contributor_data) }
  @no_contributor = !!data.at_css('NoContributor')
  @languages = data.css('Language').map { |language_data| Language.new(language_data) }
  @extents = data.css('Extent').map { |extent_data| Extent.new(extent_data) }

  @publisher_subjects = data.css('Subject').find_all { |sd|
     %w{24}.include?(sd.at_css('SubjectSchemeIdentifier')&.text) }.map { |sd| PublisherSubject.new(sd) }
  @thema_subjects = data.css('Subject').find_all { |sd|
     %w{93 94 95 96 97 98 99}.include?(sd.at_css('SubjectSchemeIdentifier')&.text) }.map { |sd| ThemaSubject.new(sd) }
  @audience_ranges = data.css('AudienceRange').map { |audience_data| AudienceRange.new(audience_data) }

  #zabezpiecznie pliku
  if protection = data.at_css("EpubTechnicalProtection")&.text
    @technical_protection =  Elibri::ONIX::Dict::Release_3_0::EpubTechnicalProtection::find_by_onix_code(protection)&.name
    @technical_protection_onix_code = protection
  end

  @edition_statement = data.at_css('EditionStatement')&.text
  if Elibri::ONIX::Dict::Release_3_0::EditionType.find_by_onix_code(data.at_css('EditionType')&.text)
    @edition_type_onix_code = data.at_css('EditionType')&.text
  end

  @number_of_illustrations = data.at_css('NumberOfIllustrations')&.text&.to_i
end

#exclusive_distributor_onix_codeObject



394
395
396
397
398
# File 'lib/elibri_onix/onix_3_0/product.rb', line 394

def exclusive_distributor_onix_code
  if @sales_restrictions.size > 0
    @sales_restrictions[0].outlet_code
  end
end

#front_coverObject

okładka ksiązki, instance SupportingResource



447
448
449
# File 'lib/elibri_onix/onix_3_0/product.rb', line 447

def front_cover
  @supporting_resources.find { |resource| resource.content_type_name == "front_cover" }
end

#inspect_include_fieldsObject



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

def inspect_include_fields
  [:record_reference, :full_title, :front_cover, :publisher, :isbn13, :ean, :premiere, :contributors, :languages, :description, :product_form_name,
    :technical_protection, :digital_formats]
end

#licence_information_setup(data) ⇒ Object



282
283
284
285
286
287
288
289
290
291
292
# File 'lib/elibri_onix/onix_3_0/product.rb', line 282

def licence_information_setup(data)
  daten = data.css('PublishingDate').find { |d| d.at_css("PublishingDateRole") && d.at_css("PublishingDateRole").text == Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::OUT_OF_PRINT_DATE }
  if daten
    date = daten.at_css('Date').text
    @licence_limited_to_before_type_cast = date
    @licence_limited_to = _parse_date(date)
    @unlimited_licence = false
  else
    @unlimited_licence = true
  end
end

#no_contributor?Boolean

flaga - true, jeśli produkt nie ma żadnego autora

Returns:

  • (Boolean)


415
416
417
# File 'lib/elibri_onix/onix_3_0/product.rb', line 415

def no_contributor?
  @no_contributor
end

#parsed_publishing_dateObject

data premiery w postaci listy [rok, miesiąc, dzień], [rok, miesiąc], [rok], lub pustej listy - jeśli data premiery nie jest znana (data premiery może nie być znana w przypadku backlisty)



474
475
476
477
478
479
480
# File 'lib/elibri_onix/onix_3_0/product.rb', line 474

def parsed_publishing_date
  if publishing_date
    publishing_date.parsed
  else
    []
  end
end

#premiereObject

data premiery, jako instancja Date (tylko wtedy, gdy dokładna data jest znana)



457
458
459
460
461
# File 'lib/elibri_onix/onix_3_0/product.rb', line 457

def premiere
  Date.new(*parsed_publishing_date) if parsed_publishing_date.size == 3
rescue ArgumentError
  nil
end

#preview_exists?Boolean

flaga, czy istnieje podgląd produktu

Returns:

  • (Boolean)


425
426
427
# File 'lib/elibri_onix/onix_3_0/product.rb', line 425

def preview_exists?
  @preview_exists
end

#product_form_features_setup(data) ⇒ Object



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/elibri_onix/onix_3_0/product.rb', line 294

def product_form_features_setup(data)
  data.each do |feature|
    ftype = feature.at_css("ProductFormFeatureType").inner_text
    v1, v2 = feature.at_css("ProductFormFeatureValue, ProductFormFeatureDescription").inner_text.split("-").map(&:to_i)

    if ftype == Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::NUMBER_OF_GAME_PIECES
      @number_of_pieces = v1
    elsif ftype == Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::GAME_PLAYERS
      @players_number_from = v1
      @players_number_to = v2
    elsif ftype == Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::GAME_PLAY_TIME
      @playing_time_from = v1
      @playing_time_to = v2
    end
  end
end

#proprietary_identifiersObject

:nodoc:



468
469
470
# File 'lib/elibri_onix/onix_3_0/product.rb', line 468

def proprietary_identifiers
  @identifiers.find_all { |i| i.identifier_type == "proprietary" }.inject({}) { |res, ident| res[ident.type_name] = ident.value; res }
end

#publishing_details_setup(data) ⇒ Object



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/elibri_onix/onix_3_0/product.rb', line 373

def publishing_details_setup(data)
  @imprint = Imprint.new(data.at_css('Imprint')) if data.at_css('Imprint')
  @publisher = Publisher.new(data.at_css('Publisher')) if data.at_css('Publisher')
  @publishing_status = data.at_css('PublishingStatus')&.text
  @city_of_publication = data.at_css("CityOfPublication")&.text
  publication_dates = data.css('PublishingDate').map do |node|
    PublishingDate.new(node)
  end
  @publishing_date = publication_dates.find { |date| date.role == Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::PUBLICATION_DATE }
  preorder_embargo_date_as_object = publication_dates.find { |date| date.role == Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::PREORDER_EMBARGO_DATE }
  @preorder_embargo_date = Date.new(*preorder_embargo_date_as_object.parsed) if preorder_embargo_date_as_object

  @sales_restrictions = data.css('SalesRestriction').map { |restriction_data| SalesRestriction.new(restriction_data) }
  #ograniczenia terytorialne
  if data.at_css("CountriesIncluded")&.text == "PL"
    @sale_restricted_to_poland = true
  else
    @sale_restricted_to_poland = false
  end
end


463
464
465
# File 'lib/elibri_onix/onix_3_0/product.rb', line 463

def related_products_record_references
  related_products.map(&:record_reference)
end

#sale_restricted_to_poland?Boolean

flaga, czy sprzedaż książki jest ograniczona do Polski

Returns:

  • (Boolean)


405
406
407
# File 'lib/elibri_onix/onix_3_0/product.rb', line 405

def sale_restricted_to_poland?
  @sale_restricted_to_poland
end

#sales_restrictions?Boolean

Returns:

  • (Boolean)


400
401
402
# File 'lib/elibri_onix/onix_3_0/product.rb', line 400

def sales_restrictions?
  @sales_restrictions.size > 0
end

#series_namesObject

lista nazwa serii, do których należy produkt



452
453
454
# File 'lib/elibri_onix/onix_3_0/product.rb', line 452

def series_names
  @series.map { |series| series[0] }
end

#unlimited_licence?Boolean

flaga informująca, czy licencja jest bezterminowa

Returns:

  • (Boolean)


410
411
412
# File 'lib/elibri_onix/onix_3_0/product.rb', line 410

def unlimited_licence?
  @unlimited_licence
end

#unnamed_persons?Boolean

flaga, czy książka to praca zbiorowa?

Returns:

  • (Boolean)


420
421
422
# File 'lib/elibri_onix/onix_3_0/product.rb', line 420

def unnamed_persons?
  @contributors.size == 1 && contributors[0].unnamed_persons
end