class CodeRay::Encoders::Debug

Debug Encoder

Fast encoder producing simple debug output.

It is readable and diff-able and is used for testing.

You cannot fully restore the tokens information from the output, because consecutive :space tokens are merged.

See also: Scanners::Debug

Constants

FILE_EXTENSION

Public Instance Methods

begin_group(kind) click to toggle source
# File lib/coderay/encoders/debug.rb, line 30
def begin_group kind
  @out << "#{kind}<"
end
begin_line(kind) click to toggle source
# File lib/coderay/encoders/debug.rb, line 38
def begin_line kind
  @out << "#{kind}["
end
end_group(kind) click to toggle source
# File lib/coderay/encoders/debug.rb, line 34
def end_group kind
  @out << '>'
end
end_line(kind) click to toggle source
# File lib/coderay/encoders/debug.rb, line 42
def end_line kind
  @out << ']'
end
text_token(text, kind) click to toggle source
# File lib/coderay/encoders/debug.rb, line 20
def text_token text, kind
  if kind == :space
    @out << text
  else
    text = text.gsub('\', '\\\\') if text.index('\')
    text = text.gsub(')',  '\\)')    if text.index(')')
    @out << "#{kind}(#{text})"
  end
end