Class: Preprocessor::BasicPreprocessor
- Inherits:
-
Object
- Object
- Preprocessor::BasicPreprocessor
- Defined in:
- lib/preprocessor.rb
Constant Summary collapse
- TAG_REGEX =
/(.)?\{\{(\S+?)(?:\s+(.*?))?\}\}/- REPLACEMENT_REGEX =
/\{-\{-(.*?)-\}-\}/
Constants included from Video
Instance Attribute Summary collapse
-
#delegate ⇒ Object
Returns the value of attribute delegate.
Instance Method Summary collapse
-
#initialize(delegate) ⇒ BasicPreprocessor
constructor
A new instance of BasicPreprocessor.
- #method_missing(sym, *args) ⇒ Object
Methods included from Footnote
#footnote, #footnotes, included
Methods included from Video
Methods included from Audio
Methods included from Image
Methods included from Utilities
Constructor Details
#initialize(delegate) ⇒ BasicPreprocessor
Returns a new instance of BasicPreprocessor.
28 29 30 |
# File 'lib/preprocessor.rb', line 28 def initialize(delegate) self.delegate = delegate end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/preprocessor.rb', line 32 def method_missing(sym, *args) text = delegate.send(sym, *args) while text.match(TAG_REGEX) text.sub!(TAG_REGEX, replacement_for($2, $3, $1 || '')) end text.gsub!(REPLACEMENT_REGEX, '{{\1}}') text end |
Instance Attribute Details
#delegate ⇒ Object
Returns the value of attribute delegate.
17 18 19 |
# File 'lib/preprocessor.rb', line 17 def delegate @delegate end |