Class: CodeRay::Encoders::Tokens

Inherits:
Encoder
  • Object
show all
Includes:
Streamable
Defined in:
lib/coderay/encoders/tokens.rb

Overview

The Tokens encoder converts the tokens to a simple readable format. It doesn’t use colors and is mainly intended for console output.

The tokens are converted with Tokens.write_token.

The format is:

<token-kind> \t <escaped token-text> \n

Example:

require 'coderay'
puts CodeRay.scan("puts 3 + 4", :ruby).tokens

prints:

ident   puts
space
integer 3
space
operator        +
space
integer 4

Constant Summary collapse

FILE_EXTENSION =
'tok'

Constants inherited from Encoder

Encoder::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Encoder

#options, #token_stream

Method Summary

Methods inherited from Encoder

const_missing, #encode, #encode_stream, #encode_tokens, #file_extension, #initialize, streamable?, #to_proc

Methods included from Plugin

#helper, #included, #plugin_host, #plugin_id, #register_for, #title

Constructor Details

This class inherits a constructor from CodeRay::Encoders::Encoder