Sha256: d81720d7c429b676e771fa42b066624d0f4da7d42edfc3092874f35c22494f7d

Contents?: true

Size: 1.09 KB

Versions: 25

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Hyrax
  module Characterization
    ##
    # @api public
    class FileSetDescription
      include Hydra::Works::MimeTypes

      ##
      # @!attribute [rw] file_set
      #   @return [Hyrax::FileSet]
      attr_accessor :file_set

      delegate :mime_type, to: :primary_file

      ##
      # @param [Hyrax::FileSet] file_set
      # @param [RDF::URI, Symbol] primary_file  the type of file_set member to
      #   use for characterization
      def initialize(file_set:, primary_file: Hyrax::FileMetadata::Use::ORIGINAL_FILE)
        self.file_set = file_set

        @primary_file_type_uri =
          Hyrax::FileMetadata::Use.uri_for(use: primary_file)
      end

      ##
      # @api public
      # @return [Hyrax::FileMetadata] the member file to use for characterization
      def primary_file
        queries.find_many_file_metadata_by_use(resource: file_set, use: @primary_file_type_uri).first ||
          Hyrax::FileMetadata.new
      end

      private

      ##
      # @api private
      def queries
        Hyrax.custom_queries
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/services/hyrax/characterization/file_set_description.rb
hyrax-5.0.0 app/services/hyrax/characterization/file_set_description.rb
hyrax-5.0.0.rc3 app/services/hyrax/characterization/file_set_description.rb
hyrax-5.0.0.rc2 app/services/hyrax/characterization/file_set_description.rb
hyrax-5.0.0.rc1 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.6.0 app/services/hyrax/characterization/file_set_description.rb
hyrax-4.0.0 app/services/hyrax/characterization/file_set_description.rb
hyrax-4.0.0.rc3 app/services/hyrax/characterization/file_set_description.rb
hyrax-4.0.0.rc2 app/services/hyrax/characterization/file_set_description.rb
hyrax-4.0.0.rc1 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.5.0 app/services/hyrax/characterization/file_set_description.rb
hyrax-4.0.0.beta2 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.4.2 app/services/hyrax/characterization/file_set_description.rb
hyrax-4.0.0.beta1 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.4.1 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.4.0 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.3.0 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.2.0 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.1.0 app/services/hyrax/characterization/file_set_description.rb
hyrax-3.0.2 app/services/hyrax/characterization/file_set_description.rb