To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / 55 / 55c44f6ea2479c136aea73b874b97160faaae047.svn-base @ 1297:0a574315af3e

History | View | Annotate | Download (737 Bytes)

1
module CodeRay
2
module Encoders
3
  
4
  # Concats the tokens into a single string, resulting in the original
5
  # code string if no tokens were removed.
6
  # 
7
  # Alias: +plain+, +plaintext+
8
  # 
9
  # == Options
10
  # 
11
  # === :separator
12
  # A separator string to join the tokens.
13
  # 
14
  # Default: empty String
15
  class Text < Encoder
16
    
17
    register_for :text
18
    
19
    FILE_EXTENSION = 'txt'
20
    
21
    DEFAULT_OPTIONS = {
22
      :separator => nil
23
    }
24
    
25
    def text_token text, kind
26
      super
27
      
28
      if @first
29
        @first = false
30
      else
31
        @out << @sep
32
      end if @sep
33
    end
34
    
35
  protected
36
    def setup options
37
      super
38
      
39
      @first = true
40
      @sep = options[:separator]
41
    end
42
    
43
  end
44
  
45
end
46
end