Class: CodeRay::Encoders::Debug
- Defined in:
- lib/coderay/encoders/debug.rb
Overview
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
Constant Summary collapse
- FILE_EXTENSION =
'raydebug'
Constants inherited from Encoder
Instance Attribute Summary
Attributes inherited from Encoder
Attributes included from Plugin
Instance Method Summary collapse
- #begin_group(kind) ⇒ Object
- #begin_line(kind) ⇒ Object
- #end_group(kind) ⇒ Object
- #end_line(kind) ⇒ Object
- #text_token(text, kind) ⇒ Object
Methods inherited from Encoder
#<<, const_missing, #encode, #encode_tokens, file_extension, #file_extension, #initialize, #token
Methods included from Plugin
#aliases, #plugin_host, #register_for, #title
Constructor Details
This class inherits a constructor from CodeRay::Encoders::Encoder
Instance Method Details
#begin_group(kind) ⇒ Object
30 31 32 |
# File 'lib/coderay/encoders/debug.rb', line 30 def begin_group kind @out << "#{kind}<" end |
#begin_line(kind) ⇒ Object
38 39 40 |
# File 'lib/coderay/encoders/debug.rb', line 38 def begin_line kind @out << "#{kind}[" end |
#end_group(kind) ⇒ Object
34 35 36 |
# File 'lib/coderay/encoders/debug.rb', line 34 def end_group kind @out << '>' end |
#end_line(kind) ⇒ Object
42 43 44 |
# File 'lib/coderay/encoders/debug.rb', line 42 def end_line kind @out << ']' end |
#text_token(text, kind) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# 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 |