Class: ActiveStorage::Analyzer
- Defined in:
- activestorage/lib/active_storage/analyzer.rb
Overview
Active Storage Analyzer
This is an abstract base class for analyzers, which extract metadata from blobs. See ActiveStorage::Analyzer::VideoAnalyzer for an example of a concrete subclass.
Direct Known Subclasses
Defined Under Namespace
Classes: AudioAnalyzer, ImageAnalyzer, NullAnalyzer, VideoAnalyzer
Instance Attribute Summary collapse
- 
  
    
      #blob  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute blob. 
Class Method Summary collapse
- 
  
    
      .accept?(blob)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Implement this method in a concrete subclass. 
- 
  
    
      .analyze_later?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Implement this method in concrete subclasses. 
Instance Method Summary collapse
- 
  
    
      #initialize(blob)  ⇒ Analyzer 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Analyzer. 
- 
  
    
      #metadata  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Override this method in a concrete subclass. 
Constructor Details
#initialize(blob) ⇒ Analyzer
Returns a new instance of Analyzer.
| 23 24 25 | # File 'activestorage/lib/active_storage/analyzer.rb', line 23 def initialize(blob) @blob = blob end | 
Instance Attribute Details
#blob ⇒ Object (readonly)
Returns the value of attribute blob.
| 9 10 11 | # File 'activestorage/lib/active_storage/analyzer.rb', line 9 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.
| 13 14 15 | # File 'activestorage/lib/active_storage/analyzer.rb', line 13 def self.accept?(blob) false end | 
.analyze_later? ⇒ Boolean
Implement this method in concrete subclasses. It will determine if blob analysis should be done in a job or performed inline. By default, analysis is enqueued in a job.
| 19 20 21 | # File 'activestorage/lib/active_storage/analyzer.rb', line 19 def self.analyze_later? true end | 
Instance Method Details
#metadata ⇒ Object
Override this method in a concrete subclass. Have it return a Hash of metadata.
| 28 29 30 | # File 'activestorage/lib/active_storage/analyzer.rb', line 28 def raise NotImplementedError end |