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.
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
- #video? ⇒ Boolean
Constructor Details
#initialize(file_set:, characterization_proxy: Hyrax.config.characterization_proxy, query_service: Hyrax.custom_queries) ⇒ FileSetTypeService
Returns a new instance of FileSetTypeService.
20 21 22 23 24 |
# File 'app/services/hyrax/file_set_type_service.rb', line 20 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.
14 15 16 |
# File 'app/services/hyrax/file_set_type_service.rb', line 14 def file_set @file_set end |
Instance Method Details
#audio? ⇒ Boolean
38 39 40 |
# File 'app/services/hyrax/file_set_type_service.rb', line 38 def audio? audio_types.include?(mime_type) end |
#metadata ⇒ Object
26 27 28 |
# File 'app/services/hyrax/file_set_type_service.rb', line 26 def @metadata ||= @queries.(resource: file_set, use: @proxy_use).first end |
#mime_type ⇒ String
32 33 34 |
# File 'app/services/hyrax/file_set_type_service.rb', line 32 def mime_type &.mime_type || Hyrax::FileMetadata::GENERIC_MIME_TYPE end |
#video? ⇒ Boolean
44 45 46 |
# File 'app/services/hyrax/file_set_type_service.rb', line 44 def video? video_types.include?(mime_type) end |