Class: ActiveStorageValidations::Analyzer

Inherits:
Object
  • Object
show all
Includes:
ASVAttachable, 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, VideoAnalyzer

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ASVLoggable

#logger

Constructor Details

#initialize(attachable) ⇒ Analyzer

Returns a new instance of Analyzer.



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

def initialize(attachable)
  @attachable = attachable
end

Instance Attribute Details

#attachableObject (readonly)

Returns the value of attribute attachable.



17
18
19
# File 'lib/active_storage_validations/analyzer.rb', line 17

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)


24
25
26
# File 'lib/active_storage_validations/analyzer.rb', line 24

def content_type
  raise NotImplementedError
end

#metadataObject

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

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/active_storage_validations/analyzer.rb', line 29

def 
  raise NotImplementedError
end