Class: ActiveStorage::Analyzer

Inherits:
Object
  • Object
show all
Includes:
Downloading
Defined in:
lib/active_storage/analyzer.rb

Overview

This is an abstract base class for analyzers, which extract metadata from blobs. See ActiveStorage::Analyzer::ImageAnalyzer for an example of a concrete subclass.

Direct Known Subclasses

ImageAnalyzer, NullAnalyzer, VideoAnalyzer

Defined Under Namespace

Classes: ImageAnalyzer, NullAnalyzer, VideoAnalyzer

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blob) ⇒ Analyzer

Returns a new instance of Analyzer.



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

def initialize(blob)
  @blob = blob
end

Instance Attribute Details

#blobObject (readonly)

Returns the value of attribute blob.



11
12
13
# File 'lib/active_storage/analyzer.rb', line 11

def blob
  @blob
end

Class Method Details

.accept?(blob) ⇒ Boolean

Implement this method in a concrete subclass. Have it return true when given a blob from which the analyzer can extract metadata.

Returns:

  • (Boolean)


15
16
17
# File 'lib/active_storage/analyzer.rb', line 15

def self.accept?(blob)
  false
end

Instance Method Details

#metadataObject

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

Raises:

  • (NotImplementedError)


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

def 
  raise NotImplementedError
end