Class CodeRay::Encoders::Tokens
In: lib/coderay/encoders/tokens.rb
Parent: Encoder

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

Methods

token  

Included Modules

Streamable

Constants

FILE_EXTENSION = 'tok'

Protected Instance methods

[Source]

    # File lib/coderay/encoders/tokens.rb, line 37
37:     def token text, kind
38:       @out << CodeRay::Tokens.write_token(text, kind)
39:     end

[Validate]