Class: Cogger::Formatters::Parsers::Position
- Inherits:
-
Object
- Object
- Cogger::Formatters::Parsers::Position
- Defined in:
- lib/cogger/formatters/parsers/position.rb
Overview
Parses template and reorders attributes based on template key positions.
Constant Summary collapse
- PATTERN =
/ % # Start. ? # Flag, width, or precision. < # Reference start. (?<name>\w+) # Name. (?::[\w]+)? # Optional delimiter and directive. > # Reference end. ? # Specifier. /x
Instance Method Summary collapse
-
#call(template, attributes) ⇒ Object
:reek:FeatureEnvy.
-
#initialize(pattern: PATTERN) ⇒ Position
constructor
A new instance of Position.
Constructor Details
Instance Method Details
#call(template, attributes) ⇒ Object
:reek:FeatureEnvy
23 24 25 26 27 28 29 |
# File 'lib/cogger/formatters/parsers/position.rb', line 23 def call template, attributes return attributes if !template || template.empty? return attributes unless template.match? pattern keys = scan template attributes.slice(*keys).merge!(attributes.except(*keys)) end |