Class: ONIX::DescriptiveDetail

Inherits:
SubsetDSL show all
Defined in:
lib/onix/descriptive_detail.rb

Instance Method Summary collapse

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

Instance Method Details

#audio?Boolean

Returns:

  • (Boolean)


463
464
465
# File 'lib/onix/descriptive_detail.rb', line 463

def audio?
  not audio_formats.empty?
end

#audio_formatObject



467
468
469
# File 'lib/onix/descriptive_detail.rb', line 467

def audio_format
  self.audio_formats.first.human if self.audio_formats.first
end

#audio_formatsObject



471
472
473
# File 'lib/onix/descriptive_detail.rb', line 471

def audio_formats
  @product_form_details.select { |fd| fd.code =~ /^A.*/ }
end

#bisac_categoriesObject



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

def bisac_categories
  @subjects.bisac
end

#bundle?Boolean

Returns:

  • (Boolean)


475
476
477
# File 'lib/onix/descriptive_detail.rb', line 475

def bundle?
  @product_composition.human=="MultipleitemRetailProduct"
end

#clil_categoriesObject



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

def clil_categories
  @subjects.clil
end

#compositionObject



399
400
401
# File 'lib/onix/descriptive_detail.rb', line 399

def composition
  @product_composition
end

#content_typesObject



407
408
409
# File 'lib/onix/descriptive_detail.rb', line 407

def content_types
  @product_content_types
end

#digital?Boolean

Returns:

  • (Boolean)


451
452
453
454
455
456
457
# File 'lib/onix/descriptive_detail.rb', line 451

def digital?
  if @product_form and @product_form.human=~/Digital/
    true
  else
    false
  end
end

#file_descriptionObject



498
499
500
# File 'lib/onix/descriptive_detail.rb', line 498

def file_description
  @product_form_description
end

#file_formatObject



479
480
481
# File 'lib/onix/descriptive_detail.rb', line 479

def file_format
  self.file_formats.first.human if self.file_formats.first
end

#file_formatsObject



489
490
491
# File 'lib/onix/descriptive_detail.rb', line 489

def file_formats
  @product_form_details.select { |fd| fd.code =~ /^E1.*/ }
end

#file_mimetypeObject



483
484
485
486
487
# File 'lib/onix/descriptive_detail.rb', line 483

def file_mimetype
  if self.file_formats.first
    self.file_formats.first.mimetype
  end
end

#filesizeObject



443
444
445
446
447
448
449
# File 'lib/onix/descriptive_detail.rb', line 443

def filesize
  if filesize_extent
    filesize_extent.bytes
  else
    nil
  end
end

#filesize_extentObject



439
440
441
# File 'lib/onix/descriptive_detail.rb', line 439

def filesize_extent
  @extents.filesize.first
end

#formObject

 shortcuts



387
388
389
# File 'lib/onix/descriptive_detail.rb', line 387

def form
  @product_form
end

#form_detailsObject



391
392
393
# File 'lib/onix/descriptive_detail.rb', line 391

def form_details
  @product_form_details
end

#form_featuresObject



395
396
397
# File 'lib/onix/descriptive_detail.rb', line 395

def form_features
  @product_form_features
end

#keywordsObject



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

def keywords
  kws=@subjects.keyword.map { |kw| kw.heading_text }.compact
  kws=kws.flat_map { |kw| kw.split(/;|,|\n/) }.map { |kw| kw.strip }
  kws.reject!{|k| k==""}
  kws
end

#language_of_textObject



518
519
520
521
522
523
524
525
# File 'lib/onix/descriptive_detail.rb', line 518

def language_of_text
  l=@languages.of_text.first
  if l
    l.code
  else
    nil
  end
end

#pagesObject



431
432
433
434
435
436
437
# File 'lib/onix/descriptive_detail.rb', line 431

def pages
  if pages_extent
    pages_extent.pages
  else
    nil
  end
end

#pages_extentObject



427
428
429
# File 'lib/onix/descriptive_detail.rb', line 427

def pages_extent
  @extents.page.first
end

#partsObject



403
404
405
# File 'lib/onix/descriptive_detail.rb', line 403

def parts
  @product_parts
end

#product_title_elementObject



423
424
425
# File 'lib/onix/descriptive_detail.rb', line 423

def product_title_element
  @title_details.distinctive_title.first.title_elements.product_level.first if @title_details.distinctive_title.first
end

#protection_typeObject



502
503
504
505
506
507
508
509
510
# File 'lib/onix/descriptive_detail.rb', line 502

def protection_type
  if @epub_technical_protections.length > 0
    if @epub_technical_protections.length == 1
      @epub_technical_protections.first.human
    else
      raise ExpectsOneButHasSeveral, @epub_technical_protections.map(&:human)
    end
  end
end

#protectionsObject



512
513
514
515
516
# File 'lib/onix/descriptive_detail.rb', line 512

def protections
  return nil if @epub_technical_protections.length == 0

  @epub_technical_protections.map(&:human)
end

#publisher_collectionObject



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

def publisher_collection
  @collections.publisher.first
end

#publisher_collection_titleObject



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

def publisher_collection_title
  if self.publisher_collection
    self.publisher_collection.title
  end
end

#reflowable?Boolean

Returns:

  • (Boolean)


493
494
495
496
# File 'lib/onix/descriptive_detail.rb', line 493

def reflowable?
  return true if @product_form_details.select { |fd| fd.code == "E200" }.length > 0
  return false if @product_form_details.select { |fd| fd.code == "E201" }.length > 0
end

#streaming?Boolean

Returns:

  • (Boolean)


459
460
461
# File 'lib/onix/descriptive_detail.rb', line 459

def streaming?
  @product_form.code=="EC"
end

#subtitleObject

:category: High level product subtitle string



419
420
421
# File 'lib/onix/descriptive_detail.rb', line 419

def subtitle
  product_title_element.subtitle if product_title_element
end

#titleObject

:category: High level product title string



413
414
415
# File 'lib/onix/descriptive_detail.rb', line 413

def title
  product_title_element.title if product_title_element
end