Class: ActiveStorage::Previewer
- Inherits:
- 
      Object
      
        - Object
- ActiveStorage::Previewer
 
- Includes:
- Downloading
- Defined in:
- lib/active_storage/previewer.rb
Overview
This is an abstract base class for previewers, which generate images from blobs. See ActiveStorage::Previewer::MuPDFPreviewer and ActiveStorage::Previewer::VideoPreviewer for examples of concrete subclasses.
Direct Known Subclasses
Defined Under Namespace
Classes: MuPDFPreviewer, PopplerPDFPreviewer, VideoPreviewer
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. 
Instance Method Summary collapse
- 
  
    
      #initialize(blob)  ⇒ Previewer 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Previewer. 
- 
  
    
      #preview  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Override this method in a concrete subclass. 
Constructor Details
#initialize(blob) ⇒ Previewer
Returns a new instance of Previewer.
| 20 21 22 | # File 'lib/active_storage/previewer.rb', line 20 def initialize(blob) @blob = blob end | 
Instance Attribute Details
#blob ⇒ Object (readonly)
Returns the value of attribute blob.
| 12 13 14 | # File 'lib/active_storage/previewer.rb', line 12 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 previewer can generate an image.
| 16 17 18 | # File 'lib/active_storage/previewer.rb', line 16 def self.accept?(blob) false end | 
Instance Method Details
#preview ⇒ Object
Override this method in a concrete subclass. Have it yield an attachable preview image (i.e. anything accepted by ActiveStorage::Attached::One#attach).
| 26 27 28 | # File 'lib/active_storage/previewer.rb', line 26 def preview raise NotImplementedError end |