Class: Ddr::Managers::TechnicalMetadataManager
- Inherits:
-
Manager
- Object
- Manager
- Ddr::Managers::TechnicalMetadataManager
show all
- Defined in:
- lib/ddr/managers/technical_metadata_manager.rb
Constant Summary
collapse
- FITS_141_TIMESTAMP_FORMAT =
"%D %l:%M %p"
- FITS_150_TIMESTAMP_FORMAT =
"%D, %l:%M %p"
- FITS_TIMESTAMP_FORMATS =
[ FITS_141_TIMESTAMP_FORMAT, FITS_150_TIMESTAMP_FORMAT ]
Instance Attribute Summary
Attributes inherited from Manager
#object
Instance Method Summary
collapse
Methods inherited from Manager
#initialize
Instance Method Details
#checksum_digest ⇒ Object
Ddr::File currently implements the ‘digest’ attribute as a set (array) of Ddr::Digest objects. This method (and the ‘checksum_value’ method that follows) assumes there is only one checksum associated with a file (as was the case in ddr-models). The current implementation simply picks the first checksum, unless/until we decide on a different approach.
77
78
79
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 77
def checksum_digest
content&.digest&.first&.type
end
|
#checksum_value ⇒ Object
81
82
83
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 81
def checksum_value
content&.digest&.first&.value
end
|
#creation_time ⇒ Object
101
102
103
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 101
def creation_time
created.map { |datestr| coerce_to_time(datestr) }.compact
end
|
#file_human_size ⇒ Object
61
62
63
64
65
66
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 61
def file_human_size
file_size.map do |fs|
"%s (%s bytes)" % [ ActiveSupport::NumberHelper.number_to_human_size(fs),
ActiveSupport::NumberHelper.number_to_delimited(fs) ]
end
end
|
#file_size ⇒ Object
57
58
59
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 57
def file_size
extent.map(&:to_i)
end
|
#fits ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 30
def fits
if object.fits_file.present?
Ddr::Fits.new(Nokogiri::XML(object.fits_file.file))
else
Ddr::Fits.new(Ddr::Fits.xml_template)
end
end
|
#fits? ⇒ Boolean
38
39
40
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 38
def fits?
!fits_version.nil?
end
|
#fits_datetime ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 46
def fits_datetime
if fits_timestamp = fits.timestamp.first
parsed = nil
FITS_TIMESTAMP_FORMATS.each do |format|
parsed = Time.zone.strptime(fits_timestamp, format) rescue nil
break if parsed
end
parsed
end
end
|
#fits_version ⇒ Object
42
43
44
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 42
def fits_version
fits.version.first
end
|
93
94
95
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 93
def ill_formed?
well_formed.any? { |v| v == "false" }
end
|
#invalid? ⇒ Boolean
85
86
87
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 85
def invalid?
valid.any? { |v| v == "false" }
end
|
#md5 ⇒ Object
68
69
70
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 68
def md5
fits.md5.first
end
|
#modification_time ⇒ Object
105
106
107
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 105
def modification_time
modified.map { |datestr| coerce_to_time(datestr) }.compact
end
|
#valid? ⇒ Boolean
89
90
91
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 89
def valid?
!invalid?
end
|
97
98
99
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 97
def well_formed?
!ill_formed?
end
|