Class: ONIX::ResourceVersion

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

#featuresObject



49
50
51
# File 'lib/onix/supporting_resource.rb', line 49

def features
  @resource_version_features
end

#file_formatObject



63
64
65
66
67
68
69
# File 'lib/onix/supporting_resource.rb', line 63

def file_format
  if ["DownloadableFile", "LinkableResource"].include?(@resource_form.human)
    if file_format_feature
      file_format_feature.value.human
    end
  end
end

#file_format_featureObject



59
60
61
# File 'lib/onix/supporting_resource.rb', line 59

def file_format_feature
  @resource_version_features.select { |f| f.type.human=="FileFormat" }.first
end

#file_mimetypeObject



71
72
73
74
75
76
77
# File 'lib/onix/supporting_resource.rb', line 71

def file_mimetype
  if ["DownloadableFile", "LinkableResource"].include?(@resource_form.human)
    if file_format_feature
      file_format_feature.value.mimetype
    end
  end
end

#filenameObject



53
54
55
56
57
# File 'lib/onix/supporting_resource.rb', line 53

def filename
  if @resource_form.human=="DownloadableFile"
    @resource_links.first
  end
end

#formObject

 shortcuts



41
42
43
# File 'lib/onix/supporting_resource.rb', line 41

def form
  @resource_form
end

#image_heightObject



97
98
99
100
101
# File 'lib/onix/supporting_resource.rb', line 97

def image_height
  if self.image_height_feature
    self.image_height_feature.value.to_i
  end
end

#image_height_featureObject



83
84
85
# File 'lib/onix/supporting_resource.rb', line 83

def image_height_feature
  @resource_version_features.image_pixels_height.first
end

#image_widthObject



91
92
93
94
95
# File 'lib/onix/supporting_resource.rb', line 91

def image_width
  if self.image_width_feature
    self.image_width_feature.value.to_i
  end
end

#image_width_featureObject



79
80
81
# File 'lib/onix/supporting_resource.rb', line 79

def image_width_feature
  @resource_version_features.image_pixels_width.first
end

#last_updatedObject



113
114
115
116
117
# File 'lib/onix/supporting_resource.rb', line 113

def last_updated
  if self.
    self..date
  end
end

#last_updated_content_dateObject



109
110
111
# File 'lib/onix/supporting_resource.rb', line 109

def 
  @content_dates.last_updated.first
end

#last_updated_utcObject



119
120
121
122
123
# File 'lib/onix/supporting_resource.rb', line 119

def last_updated_utc
  if self. and self..date
    self..date.to_time.utc.strftime('%Y%m%dT%H%M%S%z')
  end
end


45
46
47
# File 'lib/onix/supporting_resource.rb', line 45

def links
  @resource_links
end

#md5_hashObject



103
104
105
106
107
# File 'lib/onix/supporting_resource.rb', line 103

def md5_hash
  if self.md5_hash_feature
    self.md5_hash_feature.value
  end
end

#md5_hash_featureObject



87
88
89
# File 'lib/onix/supporting_resource.rb', line 87

def md5_hash_feature
  @resource_version_features.md5_hash.first
end