class ONIX::CollateralDetail

Public Instance Methods

description() click to toggle source

product description string including HTML @return [String]

# File lib/onix/collateral_detail.rb, line 17
def description
  desc_contents = @text_contents.description + @text_contents.short_description
  if desc_contents.length > 0
    desc_contents.first.text
  end
end
epub_sample_last_updated() click to toggle source

Epub sample last updated @return [Date]

# File lib/onix/collateral_detail.rb, line 81
def epub_sample_last_updated
  if self.epub_sample_resource
    self.epub_sample_resource.last_updated
  end
end
epub_sample_mimetype() click to toggle source

Epub sample mimetype @return [String]

# File lib/onix/collateral_detail.rb, line 89
def epub_sample_mimetype
  if self.epub_sample_resource
    self.epub_sample_resource.file_mimetype
  end
end
epub_sample_resource() click to toggle source
# File lib/onix/collateral_detail.rb, line 64
def epub_sample_resource
  es = @supporting_resources.sample_content.select { |sr| sr.versions.last and sr.versions.last.file_format == "Epub" }.first
  if es
    es.versions.last
  end
end
epub_sample_url() click to toggle source

Epub sample URL @return [String]

# File lib/onix/collateral_detail.rb, line 73
def epub_sample_url
  if self.epub_sample_resource
    self.epub_sample_resource.links.first.strip
  end
end
frontcover_last_updated() click to toggle source

product larger front cover last updated date

# File lib/onix/collateral_detail.rb, line 51
def frontcover_last_updated
  if self.frontcover_resource
    self.frontcover_resource.last_updated
  end
end
frontcover_mimetype() click to toggle source

product larger front cover mimetype

# File lib/onix/collateral_detail.rb, line 58
def frontcover_mimetype
  if self.frontcover_resource
    self.frontcover_resource.file_mimetype
  end
end
frontcover_resource() click to toggle source
# File lib/onix/collateral_detail.rb, line 24
def frontcover_resource
  fc = @supporting_resources.front_cover
  if fc.length > 0
    if fc.length > 1
      best_found = fc.select { |c| c.versions.last and c.versions.last.image_width }.sort { |c1, c2| c2.versions.last.image_width <=> c1.versions.last.image_width }.first
      if best_found
        # we take larger one
        best_found.versions.last
      else
        # we try first that is not gif
        fc.select { |sr| not sr.versions.last.file_format == "Gif" }.first.versions.last
      end
    else
      fc.first.versions.last
    end
  end
end
frontcover_url() click to toggle source

product larger front cover URL string @return [String]

# File lib/onix/collateral_detail.rb, line 44
def frontcover_url
  if self.frontcover_resource
    self.frontcover_resource.links.first.strip
  end
end