Class: Pragmater::Formatters::Shebang
- Inherits:
-
Object
- Object
- Pragmater::Formatters::Shebang
- Defined in:
- lib/pragmater/formatters/shebang.rb
Overview
Formats shebang pragmas in a consistent manner.
Constant Summary collapse
- PATTERN =
%r(\A\#!\s?/.*ruby\Z)
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(string, pattern: PATTERN) ⇒ Shebang
constructor
A new instance of Shebang.
Constructor Details
Instance Method Details
#call ⇒ Object
14 15 16 17 18 |
# File 'lib/pragmater/formatters/shebang.rb', line 14 def call return string unless string.match? pattern string.split("!").then { |octothorpe, path| "#{octothorpe}! #{path.strip}" } end |