Class: Phlexing::Formatter
- Inherits:
-
Object
- Object
- Phlexing::Formatter
- Defined in:
- lib/phlexing/formatter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(source, max: 80) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(source, max: 80) ⇒ Formatter
Returns a new instance of Formatter.
11 12 13 14 |
# File 'lib/phlexing/formatter.rb', line 11 def initialize(source, max: 80) @source = source.to_s.dup @max = max end |
Class Method Details
.call ⇒ Object
7 8 9 |
# File 'lib/phlexing/formatter.rb', line 7 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 |
# File 'lib/phlexing/formatter.rb', line 16 def call SyntaxTree.format(@source, @max).strip rescue SyntaxTree::Parser::ParseError, NoMethodError @source end |