Class: Cogger::Formatters::Parsers::Individual
- Inherits:
-
Object
- Object
- Cogger::Formatters::Parsers::Individual
- Defined in:
- lib/cogger/formatters/parsers/individual.rb
Overview
Sanitizes and extracts individual directives from a template.
Constant Summary collapse
- PATTERN =
rubocop:todo Lint/MixedRegexpCaptureTypes
/ % # Strict reference syntax. (?<flag>[\s#+-0*])? # Optional flag. (?<width>\d+)? # Optional width. \.? # Optional precision delimiter. (?<precision>\d+)? # Optional precision value. < # Reference start. ( # Conditional start. (?<key>\w+) # Key. : # Directive delimiter. (?<directive>\w+) # Value. | # Conditional. (?<key>\w+) # Key. ) # Conditional end. > # Reference end. (?<specifier>[ABEGXabcdefgiopsux]) # Specifier. /mx
Instance Method Summary collapse
- #call(template) ⇒ Object
-
#initialize(pattern: PATTERN) ⇒ Individual
constructor
rubocop:enable Lint/MixedRegexpCaptureTypes.
Constructor Details
#initialize(pattern: PATTERN) ⇒ Individual
rubocop:enable Lint/MixedRegexpCaptureTypes
28 29 30 |
# File 'lib/cogger/formatters/parsers/individual.rb', line 28 def initialize pattern: PATTERN @pattern = pattern end |
Instance Method Details
#call(template) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/cogger/formatters/parsers/individual.rb', line 32 def call template attributes = {} return [template, attributes] unless template.match? pattern template = sanitize_and_extract template, attributes [template, attributes] end |