Sha256: 9778d5dddafb4d2252ef5ef5b04572dab4ff7edf54f02fa53e7a8b81e7c60e52

Contents?: true

Size: 737 Bytes

Versions: 6944

Compression:

Stored size: 737 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
      
      if @first
        @first = false
      else
        @out << @sep
      end if @sep
    end
    
  protected
    def setup options
      super
      
      @first = true
      @sep = options[:separator]
    end
    
  end
  
end
end

Version data entries

6,944 entries across 6,932 versions & 73 rubygems

Version Path
coderay-1.0.0.846rc2 lib/coderay/encoders/text.rb
coderay-1.0.0.835rc1 lib/coderay/encoders/text.rb
coderay-1.0.0.831pre lib/coderay/encoders/text.rb
coderay-1.0.0.815pre lib/coderay/encoders/text.rb