Class: ActiveStorageValidations::Analyzer

Inherits:
Object
  • Object
show all
Includes:
ASVAttachable, ASVCommandable, ASVLoggable
Defined in:
lib/active_storage_validations/analyzer.rb

Overview

Active Storage Validations Analyzer

This is an abstract base class for analyzers, which extract metadata from attachables. See ActiveStorageValidations::Analyzer::VideoAnalyzer for an example of a concrete subclass.

Heavily (not to say 100%) inspired by Rails own ActiveStorage::Analyzer

Defined Under Namespace

Classes: AudioAnalyzer, ContentTypeAnalyzer, ImageAnalyzer, NullAnalyzer, PdfAnalyzer, VideoAnalyzer

Constant Summary

Constants included from ASVCommandable

ActiveStorageValidations::ASVCommandable::TERM_GRACE_SECONDS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ASVLoggable

#logger

Constructor Details

#initialize(attachable, timeout: ActiveStorageValidations.command_timeout) ⇒ Analyzer

Returns a new instance of Analyzer.



21
22
23
24
# File 'lib/active_storage_validations/analyzer.rb', line 21

def initialize(attachable, timeout: ActiveStorageValidations.command_timeout)
  @attachable = attachable
  @timeout = timeout
end

Instance Attribute Details

#attachableObject (readonly)

Returns the value of attribute attachable.



19
20
21
# File 'lib/active_storage_validations/analyzer.rb', line 19

def attachable
  @attachable
end

Instance Method Details

#content_typeObject

Override this method in a concrete subclass. Have it return a String content type.

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/active_storage_validations/analyzer.rb', line 27

def content_type
  raise NotImplementedError
end

#metadataObject

Override this method in a concrete subclass. Have it return a Hash of metadata.

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/active_storage_validations/analyzer.rb', line 32

def 
  raise NotImplementedError
end