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: Hyrax.config.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: Hyrax.config.characterization_proxy, query_service: Hyrax.custom_queries) ⇒ FileSetTypeService
Returns a new instance of FileSetTypeService.
23 24 25 26 27 |
# File 'app/services/hyrax/file_set_type_service.rb', line 23 def initialize(file_set:, characterization_proxy: Hyrax.config.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
41 42 43 |
# File 'app/services/hyrax/file_set_type_service.rb', line 41 def audio? audio_types.include?(mime_type) end |
#metadata ⇒ Object
29 30 31 |
# File 'app/services/hyrax/file_set_type_service.rb', line 29 def @metadata ||= @queries.(resource: file_set, use: @proxy_use).first end |
#mime_type ⇒ String
35 36 37 |
# File 'app/services/hyrax/file_set_type_service.rb', line 35 def mime_type &.mime_type || Hyrax::FileMetadata::GENERIC_MIME_TYPE end |