Class: ONIX::CollateralDetail

Inherits:
SubsetDSL show all
Defined in:
lib/onix/collateral_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

#descriptionObject



22
23
24
25
26
27
28
29
# File 'lib/onix/collateral_detail.rb', line 22

def description
  desc_contents=@text_contents.description + @text_contents.short_description
  if desc_contents.length > 0
    desc_contents.first.text
  else
    nil
  end
end

#epub_sample_last_updatedObject



81
82
83
84
85
# 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_mimetypeObject



87
88
89
90
91
# File 'lib/onix/collateral_detail.rb', line 87

def epub_sample_mimetype
  if self.epub_sample_resource
    self.epub_sample_resource.file_mimetype
  end
end

#epub_sample_resourceObject



68
69
70
71
72
73
# File 'lib/onix/collateral_detail.rb', line 68

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_urlObject



75
76
77
78
79
# File 'lib/onix/collateral_detail.rb', line 75

def epub_sample_url
  if self.epub_sample_resource
    self.epub_sample_resource.links.first.strip
  end
end

#frontcover_last_updatedObject



56
57
58
59
60
# File 'lib/onix/collateral_detail.rb', line 56

def frontcover_last_updated
  if self.frontcover_resource
      self.frontcover_resource.last_updated
  end
end

#frontcover_mimetypeObject



62
63
64
65
66
# File 'lib/onix/collateral_detail.rb', line 62

def frontcover_mimetype
  if self.frontcover_resource
    self.frontcover_resource.file_mimetype
  end
end

#frontcover_resourceObject

largest frontcover if multiple



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/onix/collateral_detail.rb', line 32

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_urlObject



50
51
52
53
54
# File 'lib/onix/collateral_detail.rb', line 50

def frontcover_url
  if self.frontcover_resource
    self.frontcover_resource.links.first.strip
  end
end