Class: Hyrax::FileSetTypeService
- Inherits:
-
Object
- Object
- Hyrax::FileSetTypeService
- Defined in:
- app/services/hyrax/file_set_type_service.rb
Overview
Note:
this service is for ‘Hyrax::FileSet` Valkyrie Resources. for ActiveFedora file sets see Hydra::Works::MimeTypes
Resolves file sets to a mime type. Provides a series of utility methods for figuring out what a file set is all about.
Constant Summary collapse
- DEFAULT_AUDIO_TYPES =
['audio/mp3', 'audio/mpeg', 'audio/wav', 'audio/x-wave', 'audio/x-wav', 'audio/ogg'].freeze
Instance Attribute Summary collapse
-
#file_set ⇒ Object
readonly
Returns the value of attribute file_set.
Instance Method Summary collapse
- #audio? ⇒ Boolean
-
#initialize(file_set:, characterization_proxy: ::FileSet.characterization_proxy, query_service: Hyrax.custom_queries) ⇒ FileSetTypeService
constructor
A new instance of FileSetTypeService.
- #metadata ⇒ Object
- #mime_type ⇒ String
Constructor Details
#initialize(file_set:, characterization_proxy: ::FileSet.characterization_proxy, query_service: Hyrax.custom_queries) ⇒ FileSetTypeService
TODO:
make ‘file_set_characterization_proxy` (or something better?) application-level configuration.
Returns a new instance of FileSetTypeService.
26 27 28 29 30 |
# File 'app/services/hyrax/file_set_type_service.rb', line 26 def initialize(file_set:, characterization_proxy: ::FileSet.characterization_proxy, query_service: Hyrax.custom_queries) @file_set = file_set @proxy_use = Hyrax::FileMetadata::Use.uri_for(use: characterization_proxy) @queries = query_service end |
Instance Attribute Details
#file_set ⇒ Object (readonly)
Returns the value of attribute file_set.
17 18 19 |
# File 'app/services/hyrax/file_set_type_service.rb', line 17 def file_set @file_set end |
Instance Method Details
#audio? ⇒ Boolean
44 45 46 |
# File 'app/services/hyrax/file_set_type_service.rb', line 44 def audio? audio_types.include?(mime_type) end |
#metadata ⇒ Object
32 33 34 |
# File 'app/services/hyrax/file_set_type_service.rb', line 32 def @metadata ||= @queries.(resource: file_set, use: @proxy_use).first end |
#mime_type ⇒ String
38 39 40 |
# File 'app/services/hyrax/file_set_type_service.rb', line 38 def mime_type &.mime_type || Hyrax::FileMetadata::GENERIC_MIME_TYPE end |