Sha256: 1b70dbaa2ba7983c17d36f96209dcbe2341127195dd2497a43221df69e29531d

Contents?: true

Size: 758 Bytes

Versions: 15

Compression:

Stored size: 758 Bytes

Contents

module CodeRay
module Encoders

  # 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
  #
  class Tokens < Encoder

    include Streamable
    register_for :tokens

    FILE_EXTENSION = 'tok'

  protected
    def token text, kind
      @out << CodeRay::Tokens.write_token(text, kind)
    end

  end

end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
raldred-coderay-0.9.339 ./lib/coderay/encoders/tokens.rb
raldred-coderay-0.9.3391 ./lib/coderay/encoders/tokens.rb
raldred-coderay-0.9.3431 ./lib/coderay/encoders/tokens.rb
raldred-coderay-0.9.3551 ./lib/coderay/encoders/tokens.rb
coderay-0.8.357 ./lib/coderay/encoders/tokens.rb
coderay-0.8.303 ./lib/coderay/encoders/tokens.rb
coderay-0.8.270 ./lib/coderay/encoders/tokens.rb
coderay-0.8.273 ./lib/coderay/encoders/tokens.rb
coderay-0.8.260 ./lib/coderay/encoders/tokens.rb
coderay-0.8.263 ./lib/coderay/encoders/tokens.rb
coderay-0.8.312 ./lib/coderay/encoders/tokens.rb
typo-5.1.98 vendor/gems/coderay-0.8.260/lib/coderay/encoders/tokens.rb
typo-5.2.98 vendor/gems/coderay-0.8.260/lib/coderay/encoders/tokens.rb
typo-5.2 vendor/gems/coderay-0.8.260/lib/coderay/encoders/tokens.rb
typo-5.3 vendor/gems/coderay-0.8.260/lib/coderay/encoders/tokens.rb