Sha256: 032acd13988d54b092a3562d819740f2e7795aa3473d4db5481755762c0fe310

Contents?: true

Size: 700 Bytes

Versions: 4

Compression:

Stored size: 700 Bytes

Contents

module CodeRay
module Encoders
  
  # Concats the tokens into a single string, resulting in the original
  # code string if no tokens were removed.
  # 
  # Alias: +plain+, +plaintext+
  # 
  # == Options
  # 
  # === :separator
  # A separator string to join the tokens.
  # 
  # Default: empty String
  class Text < Encoder
    
    register_for :text
    
    FILE_EXTENSION = 'txt'
    
    DEFAULT_OPTIONS = {
      :separator => nil
    }
    
    def text_token text, kind
      super
      @out << @sep if @sep
    end
    
  protected
    def setup options
      super
      @sep = options[:separator]
    end
    
    def finish options
      super.chomp @sep
    end
    
  end
  
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
coderay-1.0.0.800pre lib/coderay/encoders/text.rb
coderay-1.0.0.798.pre lib/coderay/encoders/text.rb
coderay-1.0.0.788.pre lib/coderay/encoders/text.rb
coderay-1.0.0.778.pre lib/coderay/encoders/text.rb