Class: Reek::Source::SexpFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/reek/source/sexp_formatter.rb

Overview

Formats snippets of syntax tree back into Ruby source code.

Class Method Summary collapse

Class Method Details

.format(sexp) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/reek/source/sexp_formatter.rb', line 11

def self.format(sexp)
  return sexp.to_s unless sexp.is_a? AST::Node
  lines = Unparser.unparse(sexp).split "\n"
  if lines.length > 1
    "#{lines.first} ... #{lines.last}"
  else
    lines.first
  end
end