Class: Cogger::Formatters::Parsers::Universal
- Inherits:
-
Object
- Object
- Cogger::Formatters::Parsers::Universal
- Defined in:
- lib/cogger/formatters/parsers/universal.rb
Overview
Sanitizes and extracts the universal directive a template.
Constant Summary collapse
- PATTERN =
rubocop:todo Lint/MixedRegexpCaptureTypes
%r( ( # Conditional start. \A # Search start. < # Tag start. (?<directive>\w+) # Directive. > # Tag end. | # Conditional pipe. < # Tag start. / # Tag close. (?<directive>\w+) # Directive. > # Tag end. \Z # Search end. ) # Conditional end. )mx
- KEY =
rubocop:enable Lint/MixedRegexpCaptureTypes
"directive"
Instance Method Summary collapse
- #call(template) ⇒ Object
-
#initialize(pattern: PATTERN, key: KEY) ⇒ Universal
constructor
A new instance of Universal.
Constructor Details
Instance Method Details
#call(template) ⇒ Object
34 35 36 37 38 |
# File 'lib/cogger/formatters/parsers/universal.rb', line 34 def call template return template unless template.match? pattern [template.gsub(pattern, Core::EMPTY_STRING), template.match(pattern)[key]] end |