Class: Pragmater::Formatters::General
- Inherits:
-
Object
- Object
- Pragmater::Formatters::General
- Defined in:
- lib/pragmater/formatters/general.rb
Overview
Formats general pragmas in a consistent manner.
Constant Summary collapse
- PATTERN =
/ \A # Start of line. \# # Start of comment. \s? # Space - optional. \w+ # Key - One or more word characters only. : # Delimiter. \s? # Space - optional. [\w-]+ # Value - One or more word or dash characters. \Z # End of line. /x
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(string, pattern: PATTERN) ⇒ General
constructor
A new instance of General.
Constructor Details
Instance Method Details
#call ⇒ Object
23 24 25 26 27 |
# File 'lib/pragmater/formatters/general.rb', line 23 def call return string unless string.match? pattern string.split(":").then { |key, value| "# #{key.gsub(/\#\s?/, "")}: #{value.strip}" } end |