Class: ONIX::ONIX21::Product
Instance Attribute Summary collapse
Attributes included from Attributes
#attributes
Instance Method Summary
collapse
#add_ending_period, #add_missing_periods, #add_starting_period, #at_time_price_amount_for, #current_price_amount_for, #prices_with_periods, #supplies, #supplies_excluding_tax, #supplies_for_country, #supplies_including_tax, #supplies_with_default_tax
#proprietary_ids
#isbn13
#ean
Methods inherited from SubsetDSL
#get_class, ref_to_short, short_to_ref
Methods inherited from SubsetDSL
element, elements, #get_class, get_class, inherited, #initialize, n, #parse, ref_to_short, register_elements, register_scopes, #register_subset_array, registered_elements, #registered_elements, registered_scopes, scope, short_to_ref
Methods inherited from Subset
parse, #parse, #tag_match, #unsupported
Methods included from Attributes
attribute_class, #parse_attributes, #serialized_attributes
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
538
539
540
|
# File 'lib/onix/onix21.rb', line 538
def method_missing(method)
raise "WARN #{method} not found"
end
|
Instance Attribute Details
#default_currency_code ⇒ Object
default code from ONIXMessage
312
313
314
|
# File 'lib/onix/onix21.rb', line 312
def default_currency_code
@default_currency_code
end
|
#default_language_of_text ⇒ Object
default LanguageCode from ONIXMessage
310
311
312
|
# File 'lib/onix/onix21.rb', line 310
def default_language_of_text
@default_language_of_text
end
|
Instance Method Details
#availability_date ⇒ Object
429
430
431
|
# File 'lib/onix/onix21.rb', line 429
def availability_date
nil
end
|
#available? ⇒ Boolean
461
462
463
|
# File 'lib/onix/onix21.rb', line 461
def available?
@supply_details.select { |sd| sd.available? }.length > 0
end
|
#available_for_country?(country) ⇒ Boolean
465
466
467
|
# File 'lib/onix/onix21.rb', line 465
def available_for_country?(country)
self.supplies_for_country(country).select { |s| s[:available] }.length > 0 and self.available?
end
|
#basic_main_subject ⇒ String
289
|
# File 'lib/onix/onix21.rb', line 289
element "BASICMainSubject", :text
|
#bisac_categories_codes ⇒ Object
329
330
331
332
333
334
335
336
|
# File 'lib/onix/onix21.rb', line 329
def bisac_categories_codes
cats = []
if @basic_main_subject
cats << @basic_main_subject
end
cats += (@main_subjects + @subjects).select { |s| s.scheme_identifier.human == "BisacSubjectHeading" }.map { |s| s.code }
cats
end
|
#bundle? ⇒ Boolean
453
454
455
|
# File 'lib/onix/onix21.rb', line 453
def bundle?
false
end
|
#clil_categories_codes ⇒ Object
338
339
340
|
# File 'lib/onix/onix21.rb', line 338
def clil_categories_codes
(@main_subjects + @subjects).select { |s| s.scheme_identifier.human == "Clil" }.map { |s| s.code }
end
|
#contributor_statement ⇒ String
271
|
# File 'lib/onix/onix21.rb', line 271
element "ContributorStatement", :text
|
#contributors ⇒ Array<Contributor>
270
|
# File 'lib/onix/onix21.rb', line 270
elements "Contributor", :subset
|
#countries ⇒ Object
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
# File 'lib/onix/onix21.rb', line 412
def countries
territory = Territory.new(CountryCode.list)
@sales_rights.each do |sr|
if sr.not_for_sale?
territory = territory - sr.territory
else
territory = territory + sr.territory
end
end
@not_for_sales.each do |sr|
territory = territory - sr.territory
end
territory.countries
end
|
#description ⇒ Object
391
392
393
394
395
396
397
398
|
# File 'lib/onix/onix21.rb', line 391
def description
desc_contents = @other_texts.select { |tc| tc.type.human == "MainDescription" } + @other_texts.select { |tc| tc.type.human == "LongDescription" } + @other_texts.select { |tc| tc.type.human == "ShortDescriptionannotation" }
if desc_contents.length > 0
desc_contents.first.text
else
nil
end
end
|
#digital? ⇒ Boolean
457
458
459
|
# File 'lib/onix/onix21.rb', line 457
def digital?
@product_form == "DG"
end
|
#distributor_name ⇒ Object
479
480
481
|
# File 'lib/onix/onix21.rb', line 479
def distributor_name
nil
end
|
#edition_number ⇒ Integer
305
|
# File 'lib/onix/onix21.rb', line 305
element "EditionNumber", :integer
|
#embargo_date ⇒ Object
433
434
435
|
# File 'lib/onix/onix21.rb', line 433
def embargo_date
nil
end
|
302
|
# File 'lib/onix/onix21.rb', line 302
element "EpubFormat", :text
|
#epub_sample_url ⇒ Object
519
520
521
|
# File 'lib/onix/onix21.rb', line 519
def epub_sample_url
nil
end
|
300
|
# File 'lib/onix/onix21.rb', line 300
element "EpubType", :subset
|
#epub_type_description ⇒ String
301
|
# File 'lib/onix/onix21.rb', line 301
element "EpubTypeDescription", :text
|
#epub_type_note ⇒ String
303
|
# File 'lib/onix/onix21.rb', line 303
element "EpubTypeNote", :text
|
#extents ⇒ Array<Extent>
273
|
# File 'lib/onix/onix21.rb', line 273
elements "Extent", :subset
|
#file_description ⇒ Object
501
502
503
|
# File 'lib/onix/onix21.rb', line 501
def file_description
@epub_type_description
end
|
497
498
499
|
# File 'lib/onix/onix21.rb', line 497
def file_format
@epub_type.human
end
|
#filesize ⇒ Object
510
511
512
|
# File 'lib/onix/onix21.rb', line 510
def filesize
nil
end
|
#frontcover_url ⇒ Object
483
484
485
486
487
488
489
490
|
# File 'lib/onix/onix21.rb', line 483
def frontcover_url
fc = @media_files.select { |mf| mf.media_file_type_code.human == "ImageFrontCover" && mf.media_file_link_type_code.human == "Url" }
if fc.length > 0
fc.first.link
else
nil
end
end
|
264
|
# File 'lib/onix/onix21.rb', line 264
elements "ProductIdentifier", :subset, :shortcut => :identifiers
|
#imprint_name ⇒ Object
380
381
382
383
384
|
# File 'lib/onix/onix21.rb', line 380
def imprint_name
if @imprints.first
@imprints.first.name
end
end
|
#imprints ⇒ Array<Imprint>
280
|
# File 'lib/onix/onix21.rb', line 280
elements "Imprint", :subset
|
#keywords ⇒ Object
342
343
344
345
|
# File 'lib/onix/onix21.rb', line 342
def keywords
kws = (@main_subjects + @subjects).select { |s| s.scheme_identifier.human == "Keywords" }.map { |kw| kw.heading_text }.compact
kws.map { |kw| kw.split(/;|,|\n/) }.flatten.map { |kw| kw.strip }
end
|
#language_code_of_text ⇒ Object
362
363
364
365
366
|
# File 'lib/onix/onix21.rb', line 362
def language_code_of_text
if self.language_of_text
self.language_of_text.code
end
end
|
#language_name_of_text ⇒ Object
368
369
370
371
372
|
# File 'lib/onix/onix21.rb', line 368
def language_name_of_text
if self.language_of_text
self.language_of_text.human
end
end
|
#language_of_text ⇒ Object
product LanguageCode of text
353
354
355
356
357
358
359
360
|
# File 'lib/onix/onix21.rb', line 353
def language_of_text
lang = nil
l = @languages.select { |l| l.role.human == "LanguageOfText" }.first
if l
lang = l.code
end
lang || @default_language_of_text
end
|
#languages ⇒ Array<Language>
274
|
# File 'lib/onix/onix21.rb', line 274
elements "Language", :subset
|
#main_subjects ⇒ Array<MainSubject>
290
|
# File 'lib/onix/onix21.rb', line 290
elements "MainSubject", :subset
|
275
|
# File 'lib/onix/onix21.rb', line 275
elements "MediaFile", :subset
|
#no_edition ⇒ Object
306
|
# File 'lib/onix/onix21.rb', line 306
element "NoEdition", :ignore
|
#no_series ⇒ Object
307
|
# File 'lib/onix/onix21.rb', line 307
element "NoSeries", :ignore
|
#not_for_sales ⇒ Array<NotForSale>
287
|
# File 'lib/onix/onix21.rb', line 287
elements "NotForSale", :subset
|
265
|
# File 'lib/onix/onix21.rb', line 265
element "NotificationType", :subset
|
#number_of_pages ⇒ String
277
|
# File 'lib/onix/onix21.rb', line 277
element "NumberOfPages", :text
|
#onix_outlets_values ⇒ Object
348
349
350
|
# File 'lib/onix/onix21.rb', line 348
def onix_outlets_values
[]
end
|
#other_texts ⇒ Array<OtherText>
284
|
# File 'lib/onix/onix21.rb', line 284
elements "OtherText", :subset
|
#pages ⇒ Object
469
470
471
472
473
|
# File 'lib/onix/onix21.rb', line 469
def pages
if @number_of_pages
@number_of_pages.to_i
end
end
|
#paper_linking ⇒ Object
DEPRECATED see print_product instead
528
529
530
|
# File 'lib/onix/onix21.rb', line 528
def paper_linking
self.print_product
end
|
#parts ⇒ Object
448
449
450
|
# File 'lib/onix/onix21.rb', line 448
def parts
[]
end
|
#preorder_embargo_date ⇒ Object
437
438
439
|
# File 'lib/onix/onix21.rb', line 437
def preorder_embargo_date
nil
end
|
#print_product ⇒ Object
523
524
525
|
# File 'lib/onix/onix21.rb', line 523
def print_product
@related_products.select { |rp| rp.code == "13" }.first
end
|
282
|
# File 'lib/onix/onix21.rb', line 282
element "ProductForm", :text
|
264
|
# File 'lib/onix/onix21.rb', line 264
elements "ProductIdentifier", :subset, :shortcut => :identifiers
|
#product_supplies ⇒ Array<ProductSupply>
268
|
# File 'lib/onix/onix21.rb', line 268
elements "ProductSupply", :subset
|
#product_title ⇒ Object
325
326
327
|
# File 'lib/onix/onix21.rb', line 325
def product_title
@titles.select { |td| td.type.human =~ /DistinctiveTitle/ }.first
end
|
#protection_type ⇒ Object
515
516
517
|
# File 'lib/onix/onix21.rb', line 515
def protection_type
nil
end
|
#public_announcement_date ⇒ Object
441
442
443
|
# File 'lib/onix/onix21.rb', line 441
def public_announcement_date
nil
end
|
#publication_date ⇒ String
294
|
# File 'lib/onix/onix21.rb', line 294
element "PublicationDate", :text, { :parse_lambda => lambda { |v| Date.strptime(v, "%Y%m%d") } }
|
#publisher_collection_title ⇒ Object
493
494
495
|
# File 'lib/onix/onix21.rb', line 493
def publisher_collection_title
nil
end
|
#publisher_gln ⇒ Object
532
533
534
|
# File 'lib/onix/onix21.rb', line 532
def publisher_gln
nil
end
|
#publisher_name ⇒ Object
374
375
376
377
378
|
# File 'lib/onix/onix21.rb', line 374
def publisher_name
if @publishers.first
@publishers.first.name
end
end
|
#publishers ⇒ Array<Publisher>
279
|
# File 'lib/onix/onix21.rb', line 279
elements "Publisher", :subset
|
#publishing_status ⇒ String
293
|
# File 'lib/onix/onix21.rb', line 293
element "PublishingStatus", :text
|
#raw_description ⇒ Object
400
401
402
403
404
405
406
|
# File 'lib/onix/onix21.rb', line 400
def raw_description
if self.description
Helper.strip_html(self.description).gsub(/\s+/, " ").strip
else
nil
end
end
|
#raw_file_description ⇒ Object
505
506
507
|
# File 'lib/onix/onix21.rb', line 505
def raw_file_description
file_description
end
|
#record_reference ⇒ String
263
|
# File 'lib/onix/onix21.rb', line 263
element "RecordReference", :text
|
#record_source_name ⇒ String
266
|
# File 'lib/onix/onix21.rb', line 266
element "RecordSourceName", :text
|
296
|
# File 'lib/onix/onix21.rb', line 296
elements "RelatedProduct", :subset, :shortcut => :related
|
296
|
# File 'lib/onix/onix21.rb', line 296
elements "RelatedProduct", :subset, :shortcut => :related
|
#sales_rightss ⇒ Array<SalesRights>
286
|
# File 'lib/onix/onix21.rb', line 286
elements "SalesRights", :subset, { :pluralize => false }
|
#sold_separately? ⇒ Boolean
387
388
389
|
# File 'lib/onix/onix21.rb', line 387
def sold_separately?
true
end
|
#subjects ⇒ Array<Subject>
291
|
# File 'lib/onix/onix21.rb', line 291
elements "Subject", :subset
|
#subtitle ⇒ Object
321
322
323
|
# File 'lib/onix/onix21.rb', line 321
def subtitle
product_title.subtitle
end
|
#supply_details ⇒ Array<SupplyDetail>
298
|
# File 'lib/onix/onix21.rb', line 298
elements "SupplyDetail", :subset
|
#title ⇒ Object
316
317
318
|
# File 'lib/onix/onix21.rb', line 316
def title
product_title.title
end
|
#titles ⇒ Array<Title>
267
|
# File 'lib/onix/onix21.rb', line 267
elements "Title", :subset
|