Class: Ddr::Managers::TechnicalMetadataManager

Inherits:
Manager
  • Object
show all
Defined in:
lib/ddr/managers/technical_metadata_manager.rb

Constant Summary collapse

FITS_TIMESTAMP_FORMAT =

Ex. 7/3/15 8:29 PM

"%D %l:%M %p"

Instance Attribute Summary

Attributes inherited from Manager

#object

Instance Method Summary collapse

Methods inherited from Manager

#initialize

Constructor Details

This class inherits a constructor from Ddr::Managers::Manager

Instance Method Details

#checksum_digestObject



42
43
44
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 42

def checksum_digest
  content.checksumType
end

#checksum_valueObject



46
47
48
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 46

def checksum_value
  content.checksum
end

#creation_timeObject



66
67
68
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 66

def creation_time
  created.map { |datestr| coerce_to_time(datestr) }.compact
end

#file_human_sizeObject



35
36
37
38
39
40
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 35

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_sizeObject



31
32
33
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 31

def file_size
  extent.map(&:to_i)
end

#fits?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 16

def fits?
  !fits_version.nil?
end

#fits_datetimeObject



24
25
26
27
28
29
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 24

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_versionObject



20
21
22
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 20

def fits_version
  fits.version.first
end

#ill_formed?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 58

def ill_formed?
  well_formed.any? { |v| v == "false" }
end

#index_fieldsObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 74

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_IMAGE_HEIGHT      => image_height,
    Ddr::Index::Fields::TECHMD_IMAGE_WIDTH       => image_width,
    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

Returns:

  • (Boolean)


50
51
52
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 50

def invalid?
  valid.any? { |v| v == "false" }
end

#modification_timeObject



70
71
72
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 70

def modification_time
  modified.map { |datestr| coerce_to_time(datestr) }.compact
end

#valid?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 54

def valid?
  !invalid?
end

#well_formed?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/ddr/managers/technical_metadata_manager.rb', line 62

def well_formed?
  !ill_formed?
end