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_TIMESTAMP_FORMAT =
"%D %l:%M %p"
Instance Attribute Summary
Attributes inherited from Manager
#object
Instance Method Summary
collapse
Methods inherited from Manager
#initialize
Instance Method Details
#checksum_digest ⇒ Object
57
58
59
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 57
def checksum_digest
content.checksumType
end
|
#checksum_value ⇒ Object
61
62
63
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 61
def checksum_value
content.checksum
end
|
#creation_time ⇒ Object
81
82
83
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 81
def creation_time
created.map { |datestr| coerce_to_time(datestr) }.compact
end
|
#file_human_size ⇒ Object
46
47
48
49
50
51
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 46
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
42
43
44
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 42
def file_size
extent.map(&:to_i)
end
|
#fits? ⇒ Boolean
27
28
29
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 27
def fits?
!fits_version.nil?
end
|
#fits_datetime ⇒ Object
35
36
37
38
39
40
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 35
def fits_datetime
if fits_timestamp = fits.timestamp.first
no_zone = DateTime.strptime(fits_timestamp, FITS_TIMESTAMP_FORMAT)
no_zone.change(offset: no_zone.to_time.zone)
end
end
|
#fits_version ⇒ Object
31
32
33
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 31
def fits_version
fits.version.first
end
|
73
74
75
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 73
def ill_formed?
well_formed.any? { |v| v == "false" }
end
|
#index_fields ⇒ Object
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 89
def index_fields
{ Ddr::Index::Fields::TECHMD_FITS_VERSION => fits_version,
Ddr::Index::Fields::TECHMD_FITS_DATETIME => Ddr::Utils.solr_date(fits_datetime),
Ddr::Index::Fields::TECHMD_CREATION_TIME => Ddr::Utils.solr_dates(creation_time),
Ddr::Index::Fields::TECHMD_MODIFICATION_TIME => Ddr::Utils.solr_dates(modification_time),
Ddr::Index::Fields::TECHMD_COLOR_SPACE => color_space,
Ddr::Index::Fields::TECHMD_CREATING_APPLICATION => creating_application,
Ddr::Index::Fields::TECHMD_FILE_SIZE => file_size,
Ddr::Index::Fields::TECHMD_FORMAT_LABEL => format_label,
Ddr::Index::Fields::TECHMD_FORMAT_VERSION => format_version,
Ddr::Index::Fields::TECHMD_ICC_PROFILE_NAME => icc_profile_name,
Ddr::Index::Fields::TECHMD_ICC_PROFILE_VERSION => icc_profile_version,
Ddr::Index::Fields::TECHMD_IMAGE_HEIGHT => image_height,
Ddr::Index::Fields::TECHMD_IMAGE_WIDTH => image_width,
Ddr::Index::Fields::TECHMD_MD5 => md5,
Ddr::Index::Fields::TECHMD_MEDIA_TYPE => media_type,
Ddr::Index::Fields::TECHMD_PRONOM_IDENTIFIER => pronom_identifier,
Ddr::Index::Fields::TECHMD_VALID => valid,
Ddr::Index::Fields::TECHMD_WELL_FORMED => well_formed,
}
end
|
#invalid? ⇒ Boolean
65
66
67
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 65
def invalid?
valid.any? { |v| v == "false" }
end
|
#md5 ⇒ Object
53
54
55
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 53
def md5
fits.md5.first
end
|
#modification_time ⇒ Object
85
86
87
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 85
def modification_time
modified.map { |datestr| coerce_to_time(datestr) }.compact
end
|
#valid? ⇒ Boolean
69
70
71
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 69
def valid?
!invalid?
end
|
77
78
79
|
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 77
def well_formed?
!ill_formed?
end
|