Class: Pragmater::Formatters::Main
- Inherits:
-
Object
- Object
- Pragmater::Formatters::Main
- Defined in:
- lib/pragmater/formatters/main.rb
Overview
Formats all pragmas in a consistent manner.
Constant Summary collapse
- FORMATTERS =
[General, Shebang].freeze
- PATTERN =
FORMATTERS.map { |formatter| formatter::PATTERN } .then { |patterns| Regexp.union(*patterns) } .freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(string, formatters: FORMATTERS) ⇒ Main
constructor
A new instance of Main.
Constructor Details
#initialize(string, formatters: FORMATTERS) ⇒ Main
Returns a new instance of Main.
13 14 15 16 |
# File 'lib/pragmater/formatters/main.rb', line 13 def initialize string, formatters: FORMATTERS @string = string @formatters = formatters end |
Instance Method Details
#call ⇒ Object
18 |
# File 'lib/pragmater/formatters/main.rb', line 18 def call = formatters.reduce(string) { |pragma, formatter| formatter.new(pragma).call } |