Class: Decidim::ContentParsers::BaseParser Abstract
- Inherits:
-
Object
- Object
- Decidim::ContentParsers::BaseParser
- Defined in:
- lib/decidim/content_parsers/base_parser.rb
Overview
Direct Known Subclasses
HashtagParser, InlineImagesParser, LinkParser, NewlineParser, ResourceParser, UserGroupParser, UserParser
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.
Constructor Details
#initialize(content, context) ⇒ BaseParser
Gets initialized with the ‘content` to parse
27 28 29 30 |
# File 'lib/decidim/content_parsers/base_parser.rb', line 27 def initialize(content, context) @content = content || "" @context = context end |
Instance Attribute Details
#content ⇒ String (readonly)
Returns the content to be rewritten.
18 19 20 |
# File 'lib/decidim/content_parsers/base_parser.rb', line 18 def content @content end |
#context ⇒ Hash (readonly)
Returns with context information.
21 22 23 |
# File 'lib/decidim/content_parsers/base_parser.rb', line 21 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.
58 59 60 |
# File 'lib/decidim/content_parsers/base_parser.rb', line 58 def Metadata.new end |
#rewrite ⇒ String
This method is abstract.
Subclass is expected to implement it
Parse the ‘content` and return it modified
41 42 43 |
# File 'lib/decidim/content_parsers/base_parser.rb', line 41 def rewrite content end |