Class: ONIX::Product
- Defined in:
- lib/onix/product.rb
Instance Attribute Summary collapse
-
#default_currency_code ⇒ Object
default code from ONIXMessage.
-
#default_language_of_text ⇒ Object
default LanguageCode from ONIXMessage.
Instance Method Summary collapse
-
#audio? ⇒ Boolean
:category: High level is product audio ?.
-
#audio_format ⇒ Object
:category: High level audio format string ().
-
#audio_formats ⇒ Object
:category: High level audio formats array.
-
#available? ⇒ Boolean
:category: High level is product available ?.
-
#available_for_country?(country) ⇒ Boolean
:category: High level is product available for given
country?. - #available_product_supplies ⇒ Object
-
#bisac_categories ⇒ Object
BISAC categories Subject.
-
#bisac_categories_codes ⇒ Object
:category: High level BISAC categories identifiers string array (eg: FIC000000).
-
#bundle? ⇒ Boolean
:category: High level is product a bundle of multiple parts ?.
-
#clil_categories ⇒ Object
CLIL categories Subject.
-
#clil_categories_codes ⇒ Object
:category: High level CLIL categories identifier string array.
-
#contributors ⇒ Object
:category: High level Contributor array.
-
#countries_rights ⇒ Object
:category: High level product countries rights string array.
-
#delete? ⇒ Boolean
:category: High level is a deletion notification ?.
-
#description ⇒ Object
:category: High level product description string including HTML.
-
#digital? ⇒ Boolean
:category: High level is product digital ?.
-
#distributor ⇒ Object
product distributor.
-
#distributor_gln ⇒ Object
:category: High level product distributor GLN string.
-
#distributor_name ⇒ Object
:category: High level product distributor name string.
- #distributors ⇒ Object
-
#drmized? ⇒ Boolean
:category: High level product has DRM ?.
-
#edition_number ⇒ Object
:category: High level product edition number.
-
#embargo_date ⇒ Object
date of embargo.
-
#epub_sample_last_updated ⇒ Object
:category: High level ePub sample last updated date.
-
#epub_sample_mimetype ⇒ Object
:category: High level ePub sample mimetype.
-
#epub_sample_url ⇒ Object
:category: High level ePub sample URL string.
-
#excerpts ⇒ Object
:category: High level.
-
#file_description ⇒ Object
:category: High level digital file description string.
-
#file_format ⇒ Object
:category: High level digital file format string (Epub,Pdf,Mobipocket).
-
#file_mimetype ⇒ Object
:category: High level digital file mimetype (Epub,Pdf,Mobipocket).
-
#filesize ⇒ Object
:category: High level digital file filesize in bytes.
- #form_details ⇒ Object
-
#frontcover_last_updated ⇒ Object
:category: High level product larger front cover last updated date.
-
#frontcover_mimetype ⇒ Object
:category: High level product larger front cover mimetype.
-
#frontcover_url ⇒ Object
:category: High level product larger front cover URL string.
-
#identifiers ⇒ Object
shortcuts.
-
#illustrations ⇒ Object
:category: High level.
- #imprint ⇒ Object
-
#imprint_gln ⇒ Object
:category: High level imprint GLN string.
-
#imprint_name ⇒ Object
:category: High level imprint name string.
-
#keywords ⇒ Object
:category: High level keywords string array.
-
#language_code_of_text ⇒ Object
:category: High level product language code string of text (eg: fre).
-
#language_name_of_text ⇒ Object
:category: High level product language name string of text (eg: French).
-
#language_of_text ⇒ Object
product LanguageCode of text.
-
#onix_outlets_values ⇒ Object
:category: High level List of ONIX outlets values.
-
#pages ⇒ Object
:category: High level page count.
-
#paper_linking ⇒ Object
DEPRECATED see print_product instead.
- #parse(n) ⇒ Object
-
#part_of_product ⇒ Object
:category: High level paper linking RelatedProduct.
-
#parts ⇒ Object
:category: High level bundle ProductPart array.
- #preorder_embargo_date ⇒ Object
-
#price_to_be_announced? ⇒ Boolean
:category: High level is product price to be announced ?.
-
#print_product ⇒ Object
paper linking RelatedProduct.
-
#protection_type ⇒ Object
:category: High level Protection type string (None, Watermarking, Drm, AdobeDrm).
-
#protections ⇒ Object
:category: High level List of protections type string (None, Watermarking, DRM, AdobeDRM).
- #public_announcement_date ⇒ Object
-
#publication_date ⇒ Object
:category: High level date of publication.
- #publisher ⇒ Object
-
#publisher_collection_title ⇒ Object
:category: High level publisher collection title.
-
#publisher_gln ⇒ Object
:category: High level publisher GLN string, nil if multiple publishers are found.
-
#publisher_name ⇒ Object
:category: High level publisher name string, if multiple publishers are found, then they are concatenated with “ / ”.
- #publishers ⇒ Object
-
#raw_description ⇒ Object
:category: High level raw book description string without HTML.
-
#raw_file_description ⇒ Object
:category: High level raw file description string without HTML.
- #reflowable? ⇒ Boolean
-
#related ⇒ Object
:category: High level return every related subset.
- #sales_restriction ⇒ Object
- #sold_separately? ⇒ Boolean
-
#streaming? ⇒ Boolean
:category: High level is product digital ?.
- #subjects ⇒ Object
-
#subtitle ⇒ Object
:category: High level product subtitle string.
-
#title ⇒ Object
:category: High level product title string.
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
Methods included from IsbnMethods
Methods included from EanMethods
Methods inherited from SubsetDSL
_ancestor_registered_scopes, _ancestors_registered_elements, ancestor_registered_scopes, ancestors_registered_elements, element, elements, get_class, #initialize, ref_to_short, registered_elements, registered_scopes, scope, short_to_ref, #unsupported
Methods inherited from Subset
parse, #tag_match, tag_match, #unsupported
Constructor Details
This class inherits a constructor from ONIX::SubsetDSL
Instance Attribute Details
#default_currency_code ⇒ Object
default code from ONIXMessage
317 318 319 |
# File 'lib/onix/product.rb', line 317 def default_currency_code @default_currency_code end |
#default_language_of_text ⇒ Object
default LanguageCode from ONIXMessage
315 316 317 |
# File 'lib/onix/product.rb', line 315 def default_language_of_text @default_language_of_text end |
Instance Method Details
#audio? ⇒ Boolean
:category: High level is product audio ?
486 487 488 |
# File 'lib/onix/product.rb', line 486 def audio? @descriptive_detail.audio? end |
#audio_format ⇒ Object
:category: High level audio format string ()
526 527 528 |
# File 'lib/onix/product.rb', line 526 def audio_format @descriptive_detail.audio_format end |
#audio_formats ⇒ Object
:category: High level audio formats array
520 521 522 |
# File 'lib/onix/product.rb', line 520 def audio_formats @descriptive_detail.audio_formats end |
#available? ⇒ Boolean
:category: High level is product available ?
794 795 796 |
# File 'lib/onix/product.rb', line 794 def available? self.available_product_supplies.length > 0 and not self.delete? end |
#available_for_country?(country) ⇒ Boolean
:category: High level is product available for given country ?
800 801 802 |
# File 'lib/onix/product.rb', line 800 def available_for_country?(country) self.supplies_for_country(country).select{|s| s[:available]}.length > 0 and self.available? end |
#available_product_supplies ⇒ Object
788 789 790 |
# File 'lib/onix/product.rb', line 788 def available_product_supplies @product_supplies.select{|ps| ps.available?} end |
#bisac_categories ⇒ Object
BISAC categories Subject
429 430 431 |
# File 'lib/onix/product.rb', line 429 def bisac_categories @descriptive_detail.bisac_categories end |
#bisac_categories_codes ⇒ Object
:category: High level BISAC categories identifiers string array (eg: FIC000000)
435 436 437 |
# File 'lib/onix/product.rb', line 435 def bisac_categories_codes self.bisac_categories.map{|c| c.code}.uniq end |
#bundle? ⇒ Boolean
:category: High level is product a bundle of multiple parts ?
498 499 500 |
# File 'lib/onix/product.rb', line 498 def bundle? @descriptive_detail.bundle? end |
#clil_categories ⇒ Object
CLIL categories Subject
440 441 442 |
# File 'lib/onix/product.rb', line 440 def clil_categories @descriptive_detail.clil_categories end |
#clil_categories_codes ⇒ Object
:category: High level CLIL categories identifier string array
446 447 448 |
# File 'lib/onix/product.rb', line 446 def clil_categories_codes self.clil_categories.map{|c| c.code}.uniq end |
#contributors ⇒ Object
:category: High level Contributor array
821 822 823 |
# File 'lib/onix/product.rb', line 821 def contributors @descriptive_detail.contributors end |
#countries_rights ⇒ Object
:category: High level product countries rights string array
743 744 745 746 747 748 749 750 751 752 753 754 |
# File 'lib/onix/product.rb', line 743 def countries_rights countries=[] if @publishing_detail countries+=@publishing_detail.sales_rights.map{|sr| sr.territory.countries}.flatten.uniq end if @product_supplies countries+=@product_supplies.map{|ps| ps.markets.map{|m| m.territory.countries}.flatten}.flatten.uniq end countries.uniq end |
#delete? ⇒ Boolean
:category: High level is a deletion notification ?
815 816 817 |
# File 'lib/onix/product.rb', line 815 def delete? self.notification_type.human=="Delete" end |
#description ⇒ Object
:category: High level product description string including HTML
335 336 337 338 339 340 341 |
# File 'lib/onix/product.rb', line 335 def description if @collateral_detail @collateral_detail.description else nil end end |
#digital? ⇒ Boolean
:category: High level is product digital ?
480 481 482 |
# File 'lib/onix/product.rb', line 480 def digital? @descriptive_detail.digital? end |
#distributor ⇒ Object
product distributor
645 646 647 648 649 650 651 652 653 654 655 |
# File 'lib/onix/product.rb', line 645 def distributor if self.distributors.length > 0 if self.distributors.length==1 self.distributors.first else raise ExpectsOneButHasSeveral, self.distributors.map(&:name) end else nil end end |
#distributor_gln ⇒ Object
:category: High level product distributor GLN string
669 670 671 672 673 674 675 |
# File 'lib/onix/product.rb', line 669 def distributor_gln if self.distributor self.distributor.gln else nil end end |
#distributor_name ⇒ Object
:category: High level product distributor name string
659 660 661 662 663 664 665 |
# File 'lib/onix/product.rb', line 659 def distributor_name if self.distributor self.distributor.name else nil end end |
#distributors ⇒ Object
640 641 642 |
# File 'lib/onix/product.rb', line 640 def distributors @product_supplies.map{|ps| ps.distributors}.flatten.uniq{|d| d.name} end |
#drmized? ⇒ Boolean
:category: High level product has DRM ?
470 471 472 473 474 475 476 |
# File 'lib/onix/product.rb', line 470 def drmized? if @protections.any? {|p| p =~ /Drm/ } true else false end end |
#edition_number ⇒ Object
:category: High level product edition number
393 394 395 |
# File 'lib/onix/product.rb', line 393 def edition_number @descriptive_detail.edition_number end |
#embargo_date ⇒ Object
date of embargo
717 718 719 720 721 |
# File 'lib/onix/product.rb', line 717 def if @publishing_detail @publishing_detail. end end |
#epub_sample_last_updated ⇒ Object
:category: High level ePub sample last updated date
377 378 379 380 381 |
# File 'lib/onix/product.rb', line 377 def epub_sample_last_updated if @collateral_detail @collateral_detail.epub_sample_last_updated end end |
#epub_sample_mimetype ⇒ Object
:category: High level ePub sample mimetype
385 386 387 388 389 |
# File 'lib/onix/product.rb', line 385 def epub_sample_mimetype if @collateral_detail @collateral_detail.epub_sample_mimetype end end |
#epub_sample_url ⇒ Object
:category: High level ePub sample URL string
369 370 371 372 373 |
# File 'lib/onix/product.rb', line 369 def epub_sample_url if @collateral_detail @collateral_detail.epub_sample_url end end |
#excerpts ⇒ Object
:category: High level
774 775 776 777 778 779 780 781 782 783 784 785 786 |
# File 'lib/onix/product.rb', line 774 def excerpts return [] unless @collateral_detail && @collateral_detail.supporting_resources @collateral_detail.supporting_resources.sample_content.human_code_match(:resource_mode,["Text","Multimode"]).map do |resource| { :url => resource.versions.last.links.first.strip, :form => resource.versions.last.form.human, :md5 => resource.versions.last.md5_hash, :format_code => resource.versions.last.file_format, :updated_at => resource.versions.last.last_updated_utc } end end |
#file_description ⇒ Object
:category: High level digital file description string
552 553 554 |
# File 'lib/onix/product.rb', line 552 def file_description @descriptive_detail.file_description end |
#file_format ⇒ Object
:category: High level digital file format string (Epub,Pdf,Mobipocket)
532 533 534 |
# File 'lib/onix/product.rb', line 532 def file_format @descriptive_detail.file_format end |
#file_mimetype ⇒ Object
:category: High level digital file mimetype (Epub,Pdf,Mobipocket)
546 547 548 |
# File 'lib/onix/product.rb', line 546 def file_mimetype @descriptive_detail.file_mimetype end |
#filesize ⇒ Object
:category: High level digital file filesize in bytes
514 515 516 |
# File 'lib/onix/product.rb', line 514 def filesize @descriptive_detail.filesize end |
#form_details ⇒ Object
536 537 538 |
# File 'lib/onix/product.rb', line 536 def form_details @descriptive_detail.form_details end |
#frontcover_last_updated ⇒ Object
:category: High level product larger front cover last updated date
353 354 355 356 357 |
# File 'lib/onix/product.rb', line 353 def frontcover_last_updated if @collateral_detail @collateral_detail.frontcover_last_updated end end |
#frontcover_mimetype ⇒ Object
:category: High level product larger front cover mimetype
361 362 363 364 365 |
# File 'lib/onix/product.rb', line 361 def frontcover_mimetype if @collateral_detail @collateral_detail.frontcover_mimetype end end |
#frontcover_url ⇒ Object
:category: High level product larger front cover URL string
345 346 347 348 349 |
# File 'lib/onix/product.rb', line 345 def frontcover_url if @collateral_detail @collateral_detail.frontcover_url end end |
#identifiers ⇒ Object
shortcuts
310 311 312 |
# File 'lib/onix/product.rb', line 310 def identifiers @product_identifiers end |
#illustrations ⇒ Object
:category: High level
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
# File 'lib/onix/product.rb', line 757 def illustrations return [] unless @collateral_detail && @collateral_detail.supporting_resources @collateral_detail.supporting_resources.image.map do |image_resource| { :url => image_resource.versions.last.links.first.strip, :type => image_resource.type.human, :width => image_resource.versions.last.image_width, :height => image_resource.versions.last.image_height, :caption => image_resource.caption, :format_code => image_resource.versions.last.file_format, :updated_at => image_resource.versions.last.last_updated_utc } end end |
#imprint ⇒ Object
614 615 616 617 618 619 620 |
# File 'lib/onix/product.rb', line 614 def imprint if @publishing_detail @publishing_detail.imprint else nil end end |
#imprint_gln ⇒ Object
:category: High level imprint GLN string
634 635 636 637 638 |
# File 'lib/onix/product.rb', line 634 def imprint_gln if self.imprint self.imprint.gln end end |
#imprint_name ⇒ Object
:category: High level imprint name string
624 625 626 627 628 629 630 |
# File 'lib/onix/product.rb', line 624 def imprint_name if self.imprint self.imprint.name else nil end end |
#keywords ⇒ Object
:category: High level keywords string array
452 453 454 |
# File 'lib/onix/product.rb', line 452 def keywords @descriptive_detail.keywords end |
#language_code_of_text ⇒ Object
:category: High level product language code string of text (eg: fre)
404 405 406 407 408 |
# File 'lib/onix/product.rb', line 404 def language_code_of_text if self.language_of_text self.language_of_text.code end end |
#language_name_of_text ⇒ Object
:category: High level product language name string of text (eg: French)
412 413 414 415 416 |
# File 'lib/onix/product.rb', line 412 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
398 399 400 |
# File 'lib/onix/product.rb', line 398 def language_of_text @descriptive_detail.language_of_text || @default_language_of_text end |
#onix_outlets_values ⇒ Object
:category: High level List of ONIX outlets values
827 828 829 830 831 832 833 834 835 836 |
# File 'lib/onix/product.rb', line 827 def onix_outlets_values if @publishing_detail @publishing_detail.sales_rights.map { |sri| sri.sales_restrictions.select { |sr| (!sr.start_date or sr.start_date <= Date.today) and (!sr.end_date or sr.end_date >= Date.today) }.map { |sr| sr.sales_outlets.select { |so| so.identifier and so.identifier.type.human=="OnixSalesOutletIdCode" }.map { |so| so.identifier.value } } }.flatten else [] end end |
#pages ⇒ Object
:category: High level page count
568 569 570 |
# File 'lib/onix/product.rb', line 568 def pages @descriptive_detail.pages end |
#paper_linking ⇒ Object
DEPRECATED see print_product instead
704 705 706 |
# File 'lib/onix/product.rb', line 704 def paper_linking self.print_product end |
#parse(n) ⇒ Object
838 839 840 841 842 843 |
# File 'lib/onix/product.rb', line 838 def parse(n) super parts.each do |part| part.part_of=self end end |
#part_of_product ⇒ Object
:category: High level paper linking RelatedProduct
689 690 691 692 693 |
# File 'lib/onix/product.rb', line 689 def part_of_product if .part_of_products.first end end |
#parts ⇒ Object
:category: High level bundle ProductPart array
508 509 510 |
# File 'lib/onix/product.rb', line 508 def parts @descriptive_detail.parts end |
#preorder_embargo_date ⇒ Object
723 724 725 726 727 |
# File 'lib/onix/product.rb', line 723 def if @publishing_detail @publishing_detail. end end |
#price_to_be_announced? ⇒ Boolean
:category: High level is product price to be announced ?
806 807 808 809 810 811 |
# File 'lib/onix/product.rb', line 806 def price_to_be_announced? unless self.product_supplies.empty? || self.product_supplies.first.supply_details.empty? unpriced_item_type = self.product_supplies.first.supply_details.first.unpriced_item_type end unpriced_item_type ? unpriced_item_type.human=="PriceToBeAnnounced" : false end |
#print_product ⇒ Object
paper linking RelatedProduct
697 698 699 700 701 |
# File 'lib/onix/product.rb', line 697 def print_product if .print_products.first end end |
#protection_type ⇒ Object
:category: High level Protection type string (None, Watermarking, Drm, AdobeDrm)
458 459 460 |
# File 'lib/onix/product.rb', line 458 def protection_type @descriptive_detail.protection_type end |
#protections ⇒ Object
:category: High level List of protections type string (None, Watermarking, DRM, AdobeDRM)
464 465 466 |
# File 'lib/onix/product.rb', line 464 def protections @descriptive_detail.protections end |
#public_announcement_date ⇒ Object
729 730 731 732 733 |
# File 'lib/onix/product.rb', line 729 def public_announcement_date if @publishing_detail @publishing_detail.public_announcement_date end end |
#publication_date ⇒ Object
:category: High level date of publication
710 711 712 713 714 |
# File 'lib/onix/product.rb', line 710 def publication_date if @publishing_detail @publishing_detail.publication_date end end |
#publisher ⇒ Object
590 591 592 593 594 595 596 |
# File 'lib/onix/product.rb', line 590 def publisher if @publishing_detail @publishing_detail.publisher else nil end end |
#publisher_collection_title ⇒ Object
:category: High level publisher collection title
420 421 422 |
# File 'lib/onix/product.rb', line 420 def publisher_collection_title @descriptive_detail.publisher_collection_title end |
#publisher_gln ⇒ Object
:category: High level publisher GLN string, nil if multiple publishers are found
608 609 610 611 612 |
# File 'lib/onix/product.rb', line 608 def publisher_gln if self.publishers.length==1 self.publisher.gln end end |
#publisher_name ⇒ Object
:category: High level publisher name string, if multiple publishers are found, then they are concatenated with “ / ”
600 601 602 603 604 |
# File 'lib/onix/product.rb', line 600 def publisher_name if self.publishers.length > 0 self.publishers.map{|p| p.name}.join(" / ") end end |
#publishers ⇒ Object
582 583 584 585 586 587 588 |
# File 'lib/onix/product.rb', line 582 def publishers if @publishing_detail @publishing_detail.publishers else [] end end |
#raw_description ⇒ Object
:category: High level raw book description string without HTML
574 575 576 577 578 579 580 |
# File 'lib/onix/product.rb', line 574 def raw_description if self.description Helper.strip_html(self.description).gsub(/\s+/," ").strip else nil end end |
#raw_file_description ⇒ Object
:category: High level raw file description string without HTML
558 559 560 561 562 563 564 |
# File 'lib/onix/product.rb', line 558 def raw_file_description if @descriptive_detail.file_description Helper.strip_html(@descriptive_detail.file_description).gsub(/\s+/," ").strip else nil end end |
#reflowable? ⇒ Boolean
540 541 542 |
# File 'lib/onix/product.rb', line 540 def reflowable? @descriptive_detail.reflowable? end |
#related ⇒ Object
:category: High level return every related subset
679 680 681 682 683 684 685 |
# File 'lib/onix/product.rb', line 679 def if (. + .) else [] end end |
#sales_restriction ⇒ Object
735 736 737 738 739 |
# File 'lib/onix/product.rb', line 735 def sales_restriction if @publishing_detail @publishing_detail.sales_restriction end end |
#sold_separately? ⇒ Boolean
502 503 504 |
# File 'lib/onix/product.rb', line 502 def sold_separately? @product_supplies.map{|ps| ps.supply_details.map{|sd| sd.sold_separately?}.flatten}.flatten.uniq.first end |
#streaming? ⇒ Boolean
:category: High level is product digital ?
492 493 494 |
# File 'lib/onix/product.rb', line 492 def streaming? @descriptive_detail.streaming? end |
#subjects ⇒ Object
424 425 426 |
# File 'lib/onix/product.rb', line 424 def subjects @descriptive_detail.subjects end |
#subtitle ⇒ Object
:category: High level product subtitle string
329 330 331 |
# File 'lib/onix/product.rb', line 329 def subtitle @descriptive_detail.subtitle end |
#title ⇒ Object
:category: High level product title string
323 324 325 |
# File 'lib/onix/product.rb', line 323 def title @descriptive_detail.title end |