summaryrefslogtreecommitdiff
path: root/lib/coderay/encoders/count.rb
blob: 2e60a891600b422c46c12334655d7cff9549a1dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module CodeRay
module Encoders
  
  # Returns the number of tokens.
  # 
  # Text and block tokens (:open etc.) are counted.
  class Count < Encoder

    include Streamable
    register_for :count

  protected

    def setup options
      @out = 0
    end

    def token text, kind
      @out += 1
    end
    
  end

end
end