Class: ONIX::ONIX21::Product

Inherits:
SubsetDSL show all
Includes:
EanMethods, ProductSuppliesExtractor, ProprietaryIdMethods
Defined in:
lib/onix/onix21.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ProductSuppliesExtractor

#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

Methods included from ProprietaryIdMethods

#proprietary_ids

Methods included from EanMethods

#ean

Methods inherited from SubsetDSL

get_class, ref_to_short, short_to_ref

Methods inherited from SubsetDSL

_ancestor_registered_scopes, _ancestors_registered_elements, ancestor_registered_scopes, ancestors_registered_elements, element, elements, get_class, #initialize, #parse, ref_to_short, registered_elements, registered_scopes, scope, short_to_ref, #unsupported

Methods inherited from Subset

parse, #parse, tag_match, #tag_match, #unsupported

Constructor Details

This class inherits a constructor from ONIX::SubsetDSL

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



598
599
600
# File 'lib/onix/onix21.rb', line 598

def method_missing(method)
  raise "WARN #{method} not found"
end

Instance Attribute Details

#default_currency_codeObject

default code from ONIXMessage



371
372
373
# File 'lib/onix/onix21.rb', line 371

def default_currency_code
  @default_currency_code
end

#default_language_of_textObject

default LanguageCode from ONIXMessage



369
370
371
# File 'lib/onix/onix21.rb', line 369

def default_language_of_text
  @default_language_of_text
end

Instance Method Details

#availability_dateObject



487
488
489
# File 'lib/onix/onix21.rb', line 487

def availability_date
  nil
end

#available?Boolean

Returns:

  • (Boolean)


523
524
525
# File 'lib/onix/onix21.rb', line 523

def available?
  @supply_details.select { |sd| sd.available? }.length > 0
end

#available_for_country?(country) ⇒ Boolean

Returns:

  • (Boolean)


527
528
529
# File 'lib/onix/onix21.rb', line 527

def available_for_country?(country)
  self.supplies_for_country(country).select{|s| s[:available]}.length > 0 and self.available?
end

#bisac_categories_codesObject



387
388
389
390
391
392
393
394
# File 'lib/onix/onix21.rb', line 387

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

doesn’t apply

Returns:

  • (Boolean)


515
516
517
# File 'lib/onix/onix21.rb', line 515

def bundle?
  false
end

#clil_categories_codesObject



396
397
398
# File 'lib/onix/onix21.rb', line 396

def clil_categories_codes
  (@main_subjects + @subjects).select { |s| s.scheme_identifier.human=="Clil" }.map{|s| s.code}
end

#countriesObject



470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/onix/onix21.rb', line 470

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

#descriptionObject



449
450
451
452
453
454
455
456
# File 'lib/onix/onix21.rb', line 449

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

Returns:

  • (Boolean)


519
520
521
# File 'lib/onix/onix21.rb', line 519

def digital?
  @product_form=="DG"
end

#distributor_nameObject



541
542
543
# File 'lib/onix/onix21.rb', line 541

def distributor_name
  nil
end

#edition_numberObject



537
538
539
# File 'lib/onix/onix21.rb', line 537

def edition_number
  @edition_number
end

#embargo_dateObject



491
492
493
# File 'lib/onix/onix21.rb', line 491

def embargo_date
  nil
end

#epub_sample_urlObject



581
582
583
# File 'lib/onix/onix21.rb', line 581

def epub_sample_url
  nil
end

#file_descriptionObject



563
564
565
# File 'lib/onix/onix21.rb', line 563

def file_description
  @epub_type_description
end

#file_formatObject



559
560
561
# File 'lib/onix/onix21.rb', line 559

def file_format
  @epub_type.human
end

#filesizeObject

doesn’t apply



572
573
574
# File 'lib/onix/onix21.rb', line 572

def filesize
  nil
end

#frontcover_urlObject



545
546
547
548
549
550
551
552
# File 'lib/onix/onix21.rb', line 545

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

#identifiersObject

shortcuts



364
365
366
# File 'lib/onix/onix21.rb', line 364

def identifiers
  @product_identifiers
end

#imprint_nameObject



438
439
440
441
442
# File 'lib/onix/onix21.rb', line 438

def imprint_name
  if @imprints.first
    @imprints.first.name
  end
end

#keywordsObject



400
401
402
403
# File 'lib/onix/onix21.rb', line 400

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_textObject



420
421
422
423
424
# File 'lib/onix/onix21.rb', line 420

def language_code_of_text
  if self.language_of_text
    self.language_of_text.code
  end
end

#language_name_of_textObject



426
427
428
429
430
# File 'lib/onix/onix21.rb', line 426

def language_name_of_text
  if self.language_of_text
    self.language_of_text.human
  end
end

#language_of_textObject

product LanguageCode of text



411
412
413
414
415
416
417
418
# File 'lib/onix/onix21.rb', line 411

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

#onix_outlets_valuesObject

doesn’t apply



406
407
408
# File 'lib/onix/onix21.rb', line 406

def onix_outlets_values
  []
end

#pagesObject



531
532
533
534
535
# File 'lib/onix/onix21.rb', line 531

def pages
  if @number_of_pages
    @number_of_pages.to_i
  end
end

#paper_linkingObject

DEPRECATED see print_product instead



590
591
592
# File 'lib/onix/onix21.rb', line 590

def paper_linking
  self.print_product
end

#partsObject

doesn’t apply



510
511
512
# File 'lib/onix/onix21.rb', line 510

def parts
  []
end

#preorder_embargo_dateObject



495
496
497
# File 'lib/onix/onix21.rb', line 495

def preorder_embargo_date
  nil
end


585
586
587
# File 'lib/onix/onix21.rb', line 585

def print_product
  @related_products.select { |rp| rp.code=="13" }.first
end

#product_suppliesObject



466
467
468
# File 'lib/onix/onix21.rb', line 466

def product_supplies
  [self]
end

#product_titleObject



383
384
385
# File 'lib/onix/onix21.rb', line 383

def product_title
  @titles.select { |td| td.type.human=~/DistinctiveTitle/ }.first
end

#protection_typeObject

doesn’t apply



577
578
579
# File 'lib/onix/onix21.rb', line 577

def protection_type
  nil
end

#public_announcement_dateObject



499
500
501
# File 'lib/onix/onix21.rb', line 499

def public_announcement_date
  nil
end

#publisher_collection_titleObject

 TODO



555
556
557
# File 'lib/onix/onix21.rb', line 555

def publisher_collection_title
  nil
end

#publisher_glnObject



594
595
596
# File 'lib/onix/onix21.rb', line 594

def publisher_gln
  nil
end

#publisher_nameObject



432
433
434
435
436
# File 'lib/onix/onix21.rb', line 432

def publisher_name
  if @publishers.first
    @publishers.first.name
  end
end

#raw_descriptionObject



458
459
460
461
462
463
464
# File 'lib/onix/onix21.rb', line 458

def raw_description
  if self.description
    Helper.strip_html(self.description).gsub(/\s+/, " ").strip
  else
    nil
  end
end

#raw_file_descriptionObject



567
568
569
# File 'lib/onix/onix21.rb', line 567

def raw_file_description
  file_description
end


505
506
507
# File 'lib/onix/onix21.rb', line 505

def related
  @related_products
end

#sold_separately?Boolean

doesn’t apply

Returns:

  • (Boolean)


445
446
447
# File 'lib/onix/onix21.rb', line 445

def sold_separately?
  true
end

#subtitleObject

:category: High level product subtitle string



379
380
381
# File 'lib/onix/onix21.rb', line 379

def subtitle
  product_title.subtitle
end

#titleObject



373
374
375
# File 'lib/onix/onix21.rb', line 373

def title
  product_title.title
end