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

Constant Summary collapse

ATTRIBUTES =

:nodoc:

[
  :height, :width, :thickness, :weight, :ean, :isbn13, :number_of_pages, :duration, 
  :file_size, :publisher_name, :publisher_id, :imprint_name, :current_state, :reading_age_from, :reading_age_to, 
  :table_of_contents, :description, :reviews, :excerpts, :series, :title, :subtitle, :collection_title,
  :collection_part, :full_title, :original_title, :trade_title, :parsed_publishing_date, :record_reference,
  :deletion_text, :cover_type, :cover_price, :vat, :pkwiu, :additional_info, :product_composition, 
  :publisher, :product_form, :no_contributor, :edition_statement, :edition_type_onix_code, :number_of_illustrations, :publishing_status,
  :publishing_date, :premiere, :front_cover, :series_names, :city_of_publication,
  :preview_exists, :short_description, :sale_restricted_to_poland,
  :technical_protection_onix_code, :unlimited_licence, :hyphenated_isbn, :preorder_embargo_date, :additional_trade_information,
  :number_of_pieces, :players_number_from, :players_number_to, :playing_time_from, :playing_time_to

]
RELATIONS =

:nodoc:

[
  :contributors, #IMPORTANT
  :related_products, :languages, :measures, :supply_details, :measures, :title_details,
  :collections, :extents, :thema_subjects, :audience_ranges,
  :text_contents, #IMPORTANT
  :supporting_resources, #for example: cover
  :sales_restrictions, :authors,
  :ghostwriters, :scenarists, :originators, :illustrators, :photographers, :author_of_prefaces, :drawers,
  :cover_designers, :inked_or_colored_bys, :editors, :revisors, :translators, :editor_in_chiefs, :read_bys
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspector

#attribute_for_inspect, #inspect

Constructor Details

#initialize(data) ⇒ Product

:doc:



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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/elibri_onix/onix_3_0/product.rb', line 240

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 = []
  @audience_ranges = []
  ##publishing_details
  @sales_restrictions = []
  @excerpt_infos = []
  @cover_type = nil
  #moving to parsing attributes

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

  if data.namespaces.values.any? { |uri| uri =~ /elibri/ }
    @cover_type = data.at_xpath('elibri:CoverType').try(:text) 
    @pkwiu = data.at_xpath('elibri:PKWiU').try(:text)
    @hyphenated_isbn = data.at_xpath('elibri:HyphenatedISBN').try(:text)
    @pdw_exclusiveness = data.at_xpath('elibri:PDWExclusiveness').try(:text)
    @additional_info = data.at_xpath('elibri:AdditionalInfo').try(:text)
  end

  @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
  begin
    @supply_details = data.at_css('ProductSupply').css('SupplyDetail').map { |supply_data| SupplyDetail.new(supply_data) }
  rescue
    @supply_details = []
  end

  if data.namespaces.values.any? { |uri| uri =~ /elibri/ } && (data.at_xpath('elibri:Vat') || data.at_xpath('elibri:CoverPrice'))
    @cover_price = BigDecimal(data.at_xpath('elibri:CoverPrice').try(:text)) if data.at_xpath('elibri:CoverPrice')
    @vat = data.at_xpath('elibri:Vat').try(:text).try(:to_i)
  else
    price_sd = @supply_details.find { |sd| sd.supplier && sd.supplier.role == Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_TO_RET }
    if price_sd && price_sd.price && price_sd.price && price_sd.price.type == Elibri::ONIX::Dict::Release_3_0::PriceTypeCode::RRP_WITH_TAX 
      @vat = price_sd.price.tax_rate_percent.to_i
      @cover_price = price_sd.price.amount
      @additional_trade_information = price_sd.additional_trade_information
    end
  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')

  if data.namespaces.values.any? { |uri| uri =~ /elibri/ } && data.at_xpath('elibri:preview_exists')
    @preview_exists = (data.at_xpath('elibri:preview_exists').text == "true")
  else
    @preview_exists = @supporting_resources.find { |sr| sr.content_type_name == "widget" && sr.link =~ /p.elibri.com.pl/ }.present?
  end

  product_form_features_setup(data.css("ProductFormFeature"))

  publishing_details_setup(data.at_css('PublishingDetail')) if data.at_css('PublishingDetail')
  licence_information_setup(data)
  begin
    @excerpt_infos = data.at_xpath("elibri:excerpts").xpath("elibri:excerpt").map { |node| ExcerptInfo.new(node) }
  rescue
   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

  end
  begin
    @file_infos = data.at_xpath("elibri:masters").xpath("elibri:master").map { |node| FileInfo.new(node) }
  rescue
    @file_infos = []
  end
  after_parse
end

Instance Attribute Details

#additional_infoObject (readonly)

AdditionalInfo



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

def additional_info
  @additional_info
end

#additional_trade_informationObject (readonly)

dodatkowa informacja handlowa



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

def additional_trade_information
  @additional_trade_information
end

#audience_rangesObject (readonly)

Returns the value of attribute audience_ranges.



227
228
229
# File 'lib/elibri_onix/onix_3_0/product.rb', line 227

def audience_ranges
  @audience_ranges
end

#city_of_publicationObject (readonly)

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



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

def city_of_publication
  @city_of_publication
end

#collection_partObject (readonly)

numer w cyklu



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

def collection_part
  @collection_part
end

#collection_titleObject (readonly)

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



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

def collection_title
  @collection_title
end

#collectionsObject (readonly)

Returns the value of attribute collections.



224
225
226
# File 'lib/elibri_onix/onix_3_0/product.rb', line 224

def collections
  @collections
end

#contributorsObject (readonly)

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



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

def contributors
  @contributors
end

#cover_priceObject (readonly)

sugerowana cena detaliczna brutto produktu



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

def cover_price
  @cover_price
end

#cover_typeObject (readonly)

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



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

def cover_type
  @cover_type
end

#current_stateObject (readonly)

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



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

def current_state
  @current_state
end

#deletion_textObject (readonly)

Returns the value of attribute deletion_text.



217
218
219
# File 'lib/elibri_onix/onix_3_0/product.rb', line 217

def deletion_text
  @deletion_text
end

#descriptionObject (readonly)

Opis produktu, instancja TextContent



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

def description
  @description
end

#digital_formatsObject (readonly)

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



127
128
129
# File 'lib/elibri_onix/onix_3_0/product.rb', line 127

def digital_formats
  @digital_formats
end

#durationObject (readonly)

czas trwania nagrania w audiobooku, w minutach



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

def duration
  @duration
end

#eanObject (readonly)

ean, jeśli jest inny, niż isbn13



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

def ean
  @ean
end

#edition_statementObject (readonly)

informacja o numerze wydania



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

def edition_statement
  @edition_statement
end

#edition_type_onix_codeObject (readonly)

informacja o type wydanie, kod onix



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

def edition_type_onix_code
  @edition_type_onix_code
end

#excerpt_infosObject (readonly)

informacje o fragmentach utworów (produkty cyfrowe)



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

def excerpt_infos
  @excerpt_infos
end

#excerptsObject (readonly)

Returns the value of attribute excerpts.



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

def excerpts
  @excerpts
end

#extentsObject (readonly)

Returns the value of attribute extents.



225
226
227
# File 'lib/elibri_onix/onix_3_0/product.rb', line 225

def extents
  @extents
end

#file_infosObject (readonly)

informacje o plikach master (produkty cyfrowe)



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

def file_infos
  @file_infos
end

#file_sizeObject (readonly)

Returns the value of attribute file_size.



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

def file_size
  @file_size
end

#full_titleObject (readonly)

pełen tytuł



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

def full_title
  @full_title
end

#heightObject (readonly)

:doc: wysokość w milimetrach



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

def height
  @height
end

#hyphenated_isbnObject (readonly)

isbn z kreskami



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

def hyphenated_isbn
  @hyphenated_isbn
end

#identifiersObject (readonly)

Returns the value of attribute identifiers.



229
230
231
# File 'lib/elibri_onix/onix_3_0/product.rb', line 229

def identifiers
  @identifiers
end

#imprintObject (readonly)

Returns the value of attribute imprint.



220
221
222
# File 'lib/elibri_onix/onix_3_0/product.rb', line 220

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.



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

def imprint_name
  @imprint_name
end

#isbn13Object (readonly)

isbn13 - bez kresek



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

def isbn13
  @isbn13
end

#languagesObject (readonly)

lista języków, lista intancji Language



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

def languages
  @languages
end

#licence_limited_toObject (readonly)

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



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

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



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

def licence_limited_to_before_type_cast
  @licence_limited_to_before_type_cast
end

#measuresObject (readonly)

Returns the value of attribute measures.



219
220
221
# File 'lib/elibri_onix/onix_3_0/product.rb', line 219

def measures
  @measures
end

#no_contributorObject

:nodoc:



237
238
239
# File 'lib/elibri_onix/onix_3_0/product.rb', line 237

def no_contributor
  @no_contributor
end

#notification_typeObject (readonly)

Returns the value of attribute notification_type.



216
217
218
# File 'lib/elibri_onix/onix_3_0/product.rb', line 216

def notification_type
  @notification_type
end

#number_of_illustrationsObject (readonly)

liczba ilustracji



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

def number_of_illustrations
  @number_of_illustrations
end

#number_of_pagesObject (readonly)

ilość stron w książce drukowanej



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

def number_of_pages
  @number_of_pages
end

#number_of_piecesObject (readonly)

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



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

def number_of_pieces
  @number_of_pieces
end

#original_titleObject (readonly)

tytuł oryginału



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

def original_title
  @original_title
end

#pdw_exclusivenessObject (readonly)

PDWExclusiveness



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

def pdw_exclusiveness
  @pdw_exclusiveness
end

#pkwiuObject (readonly)

PKWiU



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

def pkwiu
  @pkwiu
end

#players_number_fromObject (readonly)

min. ilość graczy - gry planszowe



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

def players_number_from
  @players_number_from
end

#players_number_toObject (readonly)

max. ilość graczy - gry planszowe



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

def players_number_to
  @players_number_to
end

#playing_time_fromObject (readonly)

min. czas gry - gry planszowe



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

def playing_time_from
  @playing_time_from
end

#playing_time_toObject (readonly)

max. czas gry - gry planszowe



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

def playing_time_to
  @playing_time_to
end

#preorder_embargo_dateObject (readonly)

Returns the value of attribute preorder_embargo_date.



234
235
236
# File 'lib/elibri_onix/onix_3_0/product.rb', line 234

def preorder_embargo_date
  @preorder_embargo_date
end

#preview_existsObject

:nodoc:



237
238
239
# File 'lib/elibri_onix/onix_3_0/product.rb', line 237

def preview_exists
  @preview_exists
end

#product_compositionObject (readonly)

Returns the value of attribute product_composition.



218
219
220
# File 'lib/elibri_onix/onix_3_0/product.rb', line 218

def product_composition
  @product_composition
end

#product_formObject (readonly)



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

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



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

def product_form_name
  @product_form_name
end

#publisherObject (readonly)

Returns the value of attribute publisher.



221
222
223
# File 'lib/elibri_onix/onix_3_0/product.rb', line 221

def publisher
  @publisher
end

#publisher_idObject (readonly)

ID wydawnictwa w systemie elibri



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

def publisher_id
  @publisher_id
end

#publisher_nameObject (readonly)

nazwa wydawnictwa



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

def publisher_name
  @publisher_name
end

#publishing_dateObject (readonly)

Returns the value of attribute publishing_date.



232
233
234
# File 'lib/elibri_onix/onix_3_0/product.rb', line 232

def publishing_date
  @publishing_date
end

#publishing_statusObject (readonly)

Returns the value of attribute publishing_status.



222
223
224
# File 'lib/elibri_onix/onix_3_0/product.rb', line 222

def publishing_status
  @publishing_status
end

#reading_age_fromObject (readonly)

Wiek czytelnika - od



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

def reading_age_from
  @reading_age_from
end

#reading_age_toObject (readonly)

Wiek czytelnika - do



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

def reading_age_to
  @reading_age_to
end

#record_referenceObject (readonly)

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



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

def record_reference
  @record_reference
end

Returns the value of attribute related_products.



233
234
235
# File 'lib/elibri_onix/onix_3_0/product.rb', line 233

def related_products
  @related_products
end

#reviewsObject (readonly)

Returns the value of attribute reviews.



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

def reviews
  @reviews
end

#sale_restricted_to_polandObject

:nodoc:



237
238
239
# File 'lib/elibri_onix/onix_3_0/product.rb', line 237

def sale_restricted_to_poland
  @sale_restricted_to_poland
end

#sales_restrictionsObject (readonly)

Returns the value of attribute sales_restrictions.



231
232
233
# File 'lib/elibri_onix/onix_3_0/product.rb', line 231

def sales_restrictions
  @sales_restrictions
end

#seriesObject (readonly)

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



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

def series
  @series
end

#short_descriptionObject (readonly)

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



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

def short_description
  @short_description
end

#subtitleObject (readonly)

podtytuł



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

def subtitle
  @subtitle
end

#supply_detailsObject (readonly)

Returns the value of attribute supply_details.



228
229
230
# File 'lib/elibri_onix/onix_3_0/product.rb', line 228

def supply_details
  @supply_details
end

#supporting_resourcesObject (readonly)

Returns the value of attribute supporting_resources.



230
231
232
# File 'lib/elibri_onix/onix_3_0/product.rb', line 230

def supporting_resources
  @supporting_resources
end

#table_of_contentsObject (readonly)

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



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

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



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

def technical_protection
  @technical_protection
end

#technical_protection_onix_codeObject (readonly)

Returns the value of attribute technical_protection_onix_code.



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

def technical_protection_onix_code
  @technical_protection_onix_code
end

#text_contentsObject (readonly)

:nodoc:



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

def text_contents
  @text_contents
end

#thema_subjectsObject (readonly)

Returns the value of attribute thema_subjects.



226
227
228
# File 'lib/elibri_onix/onix_3_0/product.rb', line 226

def thema_subjects
  @thema_subjects
end

#thicknessObject (readonly)

gruboś w milimetrach



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

def thickness
  @thickness
end

#titleObject (readonly)

tytuł ksiażki



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

def title
  @title
end

#title_detailsObject (readonly)

Returns the value of attribute title_details.



223
224
225
# File 'lib/elibri_onix/onix_3_0/product.rb', line 223

def title_details
  @title_details
end

#to_xmlObject (readonly)

reprezentacja xml dla produktu



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

def to_xml
  @to_xml
end

#trade_titleObject (readonly)

Returns the value of attribute trade_title.



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

def trade_title
  @trade_title
end

#unlimited_licenceObject

:nodoc:



237
238
239
# File 'lib/elibri_onix/onix_3_0/product.rb', line 237

def unlimited_licence
  @unlimited_licence
end

#vatObject (readonly)

stawka VAT



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

def vat
  @vat
end

#weightObject (readonly)

waga w gramach



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

def weight
  @weight
end

#widthObject (readonly)

szerokość w milimetrach



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

def width
  @width
end

Instance Method Details

#authorsObject



473
474
475
# File 'lib/elibri_onix/onix_3_0/product.rb', line 473

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

#collateral_details_setup(data) ⇒ Object



417
418
419
420
# File 'lib/elibri_onix/onix_3_0/product.rb', line 417

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



367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/elibri_onix/onix_3_0/product.rb', line 367

def descriptive_details_setup(data)
  @product_composition = data.at_css('ProductComposition').try(:text)
  @product_form = data.at_css('ProductForm').try(:text)
  if @product_form
    if @product_form.starts_with?("B") && !@cover_type
      @cover_type = Elibri::ONIX::Dict::CoverType.determine_cover_type(@product_form, data.at_css('ProductFormDetail').try(:text))
    end
    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.starts_with?("B") ? "BA" : @product_form
    if Elibri::ONIX::Dict::Release_3_0::ProductFormCode::find_by_onix_code(simplified_product_form).try!(:digital?)
      @digital_formats = []
      data.css("ProductFormDetail").each do |format|
        format_name = Elibri::ONIX::Dict::Release_3_0::ProductFormDetail::find_by_onix_code(format.text).try(:name)
        @digital_formats << format_name.upcase.gsub("MOBIPOCKET", "MOBI") if format_name
      end
    end

  end
  if classification = data.css('ProductClassification').find { |cl| 
     cl.at_css('ProductClassificationType').text == Elibri::ONIX::Dict::Release_3_0::ProductClassificationType::PKWIU }
    @pkwiu  = classification.at_css('ProductClassificationCode').text
  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) }
  @thema_subjects = data.css('Subject').find_all { |sd| 
     %w{93 94 95 96 97 98 99}.include?(sd.at_css('SubjectSchemeIdentifier').try(: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").try(:text)
    @technical_protection =  Elibri::ONIX::Dict::Release_3_0::EpubTechnicalProtection::find_by_onix_code(protection).try(:name)
    @technical_protection_onix_code = protection
  end

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

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

#front_coverObject

okładka ksiązki, instance SupportingResource



491
492
493
# File 'lib/elibri_onix/onix_3_0/product.rb', line 491

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

#inspect_include_fieldsObject



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

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



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/elibri_onix/onix_3_0/product.rb', line 327

def licence_information_setup(data)
  if data.namespaces.values.any? { |uri| uri =~ /elibri/ } && (data.at_xpath("elibri:SaleNotRestricted") || data.at_xpath("elibri:SaleRestrictedTo"))
    if data.at_xpath("elibri:SaleNotRestricted")
      @unlimited_licence = true
    elsif date = data.at_xpath("elibri:SaleRestrictedTo").try(:text)
      @unlimited_licence = false
      @licence_limited_to_before_type_cast = date
      @licence_limited_to = Date.new(date[0...4].to_i, date[4...6].to_i, date[6...8].to_i)
    end
  else
    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 = Date.new(date[0...4].to_i, date[4...6].to_i, date[6...8].to_i)
      @unlimited_licence = false
    else
      @unlimited_licence = true
    end

  end
end

#no_contributor?Boolean

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

Returns:

  • (Boolean)


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

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)



518
519
520
521
522
523
524
525
526
527
# File 'lib/elibri_onix/onix_3_0/product.rb', line 518

def parsed_publishing_date
  if sales_restrictions?
    date = sales_restrictions[0].end_date
    [date.year, date.month, date.day]
  elsif publishing_date
    publishing_date.parsed
  else
    []
  end
end

#premiereObject

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



501
502
503
504
505
# File 'lib/elibri_onix/onix_3_0/product.rb', line 501

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)


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

def preview_exists?
  @preview_exists
end

#product_form_features_setup(data) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/elibri_onix/onix_3_0/product.rb', line 350

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:



512
513
514
# File 'lib/elibri_onix/onix_3_0/product.rb', line 512

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



422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/elibri_onix/onix_3_0/product.rb', line 422

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').try(:text)
  @city_of_publication = data.at_css("CityOfPublication").try(: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").try(:text) == "PL"
    @sale_restricted_to_poland = true
  else
    @sale_restricted_to_poland = false
  end

end


507
508
509
# File 'lib/elibri_onix/onix_3_0/product.rb', line 507

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)


449
450
451
# File 'lib/elibri_onix/onix_3_0/product.rb', line 449

def sale_restricted_to_poland?
  @sale_restricted_to_poland
end

#sales_restrictions?Boolean

Returns:

  • (Boolean)


444
445
446
# File 'lib/elibri_onix/onix_3_0/product.rb', line 444

def sales_restrictions?
  @sales_restrictions.size > 0
end

#series_namesObject

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



496
497
498
# File 'lib/elibri_onix/onix_3_0/product.rb', line 496

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

#unlimited_licence?Boolean

flaga informująca, czy licencja jest bezterminowa

Returns:

  • (Boolean)


454
455
456
# File 'lib/elibri_onix/onix_3_0/product.rb', line 454

def unlimited_licence?
  @unlimited_licence
end

#unnamed_persons?Boolean

flaga, czy książka to praca zbiorowa?

Returns:

  • (Boolean)


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

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