class ONIX::DescriptiveDetail

Public Instance Methods

audio?() click to toggle source

is digital offer audio ? @return [Boolean]

# File lib/onix/descriptive_detail.rb, line 179
def audio?
  not audio_formats.empty?
end
audio_format() click to toggle source

@return [String]

# File lib/onix/descriptive_detail.rb, line 184
def audio_format
  self.audio_formats.first.human if self.audio_formats.first
end
audio_formats() click to toggle source

@return [Array<ProductFormDetail>]

# File lib/onix/descriptive_detail.rb, line 105
def audio_formats
  @product_form_details.select { |fd| fd.code =~ /^A.*/ }
end
bisac_categories() click to toggle source

BISAC categories @return [Array<Subject>]

# File lib/onix/descriptive_detail.rb, line 111
def bisac_categories
  @subjects.bisac
end
bisac_categories_codes() click to toggle source

BISAC categories identifiers string array (eg: FIC000000) @return [Array<String>]

# File lib/onix/descriptive_detail.rb, line 253
def bisac_categories_codes
  self.bisac_categories.map { |c| c.code }.uniq
end
bundle?() click to toggle source

is digital offer a bundle ? @return [Boolean]

# File lib/onix/descriptive_detail.rb, line 190
def bundle?
  @product_composition.human == "MultipleComponentRetailProduct"
end
clil_categories() click to toggle source

CLIL categories @return [Array<Subject>]

# File lib/onix/descriptive_detail.rb, line 117
def clil_categories
  @subjects.clil
end
clil_categories_codes() click to toggle source

CLIL categories identifier string array @return [Array<String>]

# File lib/onix/descriptive_detail.rb, line 259
def clil_categories_codes
  self.clil_categories.map { |c| c.code }.uniq
end
digital?() click to toggle source

is digital ? @return [Boolean]

# File lib/onix/descriptive_detail.rb, line 157
def digital?
  if @product_form and @product_form.human =~ /Digital/
    true
  else
    false
  end
end
drmized?() click to toggle source

digital offer has DRM ? @return [Boolean]

# File lib/onix/descriptive_detail.rb, line 167
def drmized?
  @protections.any? { |p| p =~ /Drm/ }
end
file_format() click to toggle source

digital file format string (Epub,Pdf,AmazonKindle) @return [String]

# File lib/onix/descriptive_detail.rb, line 196
def file_format
  file_formats.first.human if file_formats.first
end
file_formats() click to toggle source

@return [Array<ProductFormDetail>]

# File lib/onix/descriptive_detail.rb, line 90
def file_formats
  @product_form_details.select { |fd| fd.code =~ /^E1.*/ }
end
file_mimetype() click to toggle source

digital file format mimetype @return [String]

# File lib/onix/descriptive_detail.rb, line 202
def file_mimetype
  if file_formats.first
    file_formats.first.mimetype
  end
end
filesize() click to toggle source

file size in bytes @return [Integer]

# File lib/onix/descriptive_detail.rb, line 147
def filesize
  if filesize_extent
    filesize_extent.bytes
  else
    nil
  end
end
filesize_extent() click to toggle source

@return [Extent]

# File lib/onix/descriptive_detail.rb, line 100
def filesize_extent
  @extents.filesize.first
end
keywords() click to toggle source

keywords string array @return [Array<String>]

# File lib/onix/descriptive_detail.rb, line 265
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_text() click to toggle source

language of text @return [String]

# File lib/onix/descriptive_detail.rb, line 236
def language_of_text
  l = @languages.of_text.first
  if l
    l.code
  end
end
pages() click to toggle source

page count @return [Integer]

# File lib/onix/descriptive_detail.rb, line 139
def pages
  if pages_extent
    pages_extent.pages
  end
end
pages_extent() click to toggle source

@return [Extent]

# File lib/onix/descriptive_detail.rb, line 80
def pages_extent
  @extents.page.first
end
product_title_element() click to toggle source

@return [TitleElement]

# File lib/onix/descriptive_detail.rb, line 85
def product_title_element
  @title_details.distinctive_title.first.title_elements.product_level.first if @title_details.distinctive_title.first
end
protection_type() click to toggle source

protection type string @return [String]

# File lib/onix/descriptive_detail.rb, line 217
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
protections() click to toggle source

protections string array @return [Array<String>]

# File lib/onix/descriptive_detail.rb, line 229
def protections
  return [] if @epub_technical_protections.length == 0
  @epub_technical_protections.map(&:human)
end
publisher_collection() click to toggle source

@return [Collection]

# File lib/onix/descriptive_detail.rb, line 95
def publisher_collection
  @collections.publisher.first
end
publisher_collection_title() click to toggle source

publisher collection title @return [String]

# File lib/onix/descriptive_detail.rb, line 245
def publisher_collection_title
  if self.publisher_collection
    self.publisher_collection.title
  end
end
reflowable?() click to toggle source

is digital file reflowable ? @return [Boolean]

# File lib/onix/descriptive_detail.rb, line 210
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?() click to toggle source

is digital offer streaming ? @return [Boolean]

# File lib/onix/descriptive_detail.rb, line 173
def streaming?
  @product_form.code == "EC"
end
subtitle() click to toggle source

product subtitle string @return [String]

# File lib/onix/descriptive_detail.rb, line 133
def subtitle
  product_title_element.subtitle if product_title_element
end
title() click to toggle source

product title string @return [String]

# File lib/onix/descriptive_detail.rb, line 127
def title
  product_title_element.title if product_title_element
end