Sha256: 09eacd1445defef8937f6f740df89ee2a979172f6224b4a5c30551a109894fcc

Contents?: true

Size: 657 Bytes

Versions: 1

Compression:

Stored size: 657 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+
  # 
  # == 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

1 entries across 1 versions & 1 rubygems

Version Path
coderay-1.0.0.738.pre ./lib/coderay/encoders/text.rb