Class: Hyrax::ActiveEncode::ActiveEncodeDerivativeService
- Inherits:
-
DerivativeService
- Object
- DerivativeService
- Hyrax::ActiveEncode::ActiveEncodeDerivativeService
- Defined in:
- app/services/hyrax/active_encode/active_encode_derivative_service.rb
Instance Attribute Summary collapse
-
#encode_class ⇒ Object
Returns the value of attribute encode_class.
-
#options_service_class ⇒ Object
Returns the value of attribute options_service_class.
Instance Method Summary collapse
-
#cleanup_derivatives ⇒ Object
TODO: Implement this?.
- #create_derivatives(filename) ⇒ Object
-
#derivative_url(file_label) ⇒ Object
What should this return?.
-
#initialize(file_set, encode_class: ::ActiveEncode::Base, options_service_class: DefaultOptionService, local_streaming: true) ⇒ ActiveEncodeDerivativeService
constructor
A new instance of ActiveEncodeDerivativeService.
- #local_streaming? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(file_set, encode_class: ::ActiveEncode::Base, options_service_class: DefaultOptionService, local_streaming: true) ⇒ ActiveEncodeDerivativeService
Returns a new instance of ActiveEncodeDerivativeService.
9 10 11 12 13 14 |
# File 'app/services/hyrax/active_encode/active_encode_derivative_service.rb', line 9 def initialize(file_set, encode_class: ::ActiveEncode::Base, options_service_class: DefaultOptionService, local_streaming: true) super(file_set) @encode_class = encode_class @options_service_class = @local_streaming = local_streaming end |
Instance Attribute Details
#encode_class ⇒ Object
Returns the value of attribute encode_class.
7 8 9 |
# File 'app/services/hyrax/active_encode/active_encode_derivative_service.rb', line 7 def encode_class @encode_class end |
#options_service_class ⇒ Object
Returns the value of attribute options_service_class.
7 8 9 |
# File 'app/services/hyrax/active_encode/active_encode_derivative_service.rb', line 7 def @options_service_class end |
Instance Method Details
#cleanup_derivatives ⇒ Object
TODO: Implement this?
36 |
# File 'app/services/hyrax/active_encode/active_encode_derivative_service.rb', line 36 def cleanup_derivatives; end |
#create_derivatives(filename) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/services/hyrax/active_encode/active_encode_derivative_service.rb', line 16 def create_derivatives(filename) = .call(@file_set) .each do |option| option[:file_set_id] = file_set.id option[:local_streaming] = true if local_streaming? end Hydra::Derivatives::ActiveEncodeDerivatives.create(filename, outputs: , encode_class: @encode_class) end |
#derivative_url(file_label) ⇒ Object
What should this return?
26 27 28 29 |
# File 'app/services/hyrax/active_encode/active_encode_derivative_service.rb', line 26 def derivative_url(file_label) derivative = file_set.derivatives.find { |d| d.label.first == file_label } derivative.nil? ? nil : derivative.external_file_uri.first end |
#local_streaming? ⇒ Boolean
38 39 40 |
# File 'app/services/hyrax/active_encode/active_encode_derivative_service.rb', line 38 def local_streaming? @local_streaming == true end |
#valid? ⇒ Boolean
31 32 33 |
# File 'app/services/hyrax/active_encode/active_encode_derivative_service.rb', line 31 def valid? supported_mime_types.include?(file_set.mime_type) && file_set.class.include?(Hyrax::ActiveEncode::FileSetBehavior) end |