Class: Decidim::ContentParsers::BaseParser Abstract
- Inherits:
 - 
      Object
      
        
- Object
 - Decidim::ContentParsers::BaseParser
 
 
- Includes:
 - Decidim::ContentProcessor::Common
 
- Defined in:
 - lib/decidim/content_parsers/base_parser.rb
 
Overview
Direct Known Subclasses
InlineImagesParser, LinkParser, NewlineParser, ResourceParser, TagParser
Constant Summary collapse
- Metadata =
          
Class used as a container for metadata
 Class.new
Instance Attribute Summary collapse
- 
  
    
      #content  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
The content to be rewritten.
 - 
  
    
      #context  ⇒ Hash 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
With context information.
 
Instance Method Summary collapse
- 
  
    
      #initialize(content, context)  ⇒ BaseParser 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Gets initialized with the ‘content` to parse.
 - 
  
    
      #metadata  ⇒ Metadata 
    
    
  
  
  
  
  
  abstract
  
  
  
    
Collects and returns metadata.
 - 
  
    
      #rewrite  ⇒ String 
    
    
  
  
  
  
  
  abstract
  
  
  
    
Parse the ‘content` and return it modified.
 
Methods included from Decidim::ContentProcessor::Common
#html_content?, #html_fragment
Constructor Details
#initialize(content, context) ⇒ BaseParser
Gets initialized with the ‘content` to parse
      29 30 31 32  | 
    
      # File 'lib/decidim/content_parsers/base_parser.rb', line 29 def initialize(content, context) @content = content || "" @context = context end  | 
  
Instance Attribute Details
#content ⇒ String (readonly)
Returns the content to be rewritten.
      20 21 22  | 
    
      # File 'lib/decidim/content_parsers/base_parser.rb', line 20 def content @content end  | 
  
#context ⇒ Hash (readonly)
Returns with context information.
      23 24 25  | 
    
      # File 'lib/decidim/content_parsers/base_parser.rb', line 23 def context @context end  | 
  
Instance Method Details
#metadata ⇒ Metadata
  This method is abstract.
  
Subclass is expected to implement it
Collects and returns metadata. This metadata is accessible at parsing time so it can be acted upon (sending emails to the users) or maybe even stored at the DB for later consultation.
      60 61 62  | 
    
      # File 'lib/decidim/content_parsers/base_parser.rb', line 60 def Metadata.new end  | 
  
#rewrite ⇒ String
  This method is abstract.
  
Subclass is expected to implement it
Parse the ‘content` and return it modified
      43 44 45  | 
    
      # File 'lib/decidim/content_parsers/base_parser.rb', line 43 def rewrite content end  |