Sha256: 9c67ac3730a89ae6268af2f26ae71d3a14d48c0b66c4187fb13d4910295cacd4

Contents?: true

Size: 477 Bytes

Versions: 5

Compression:

Stored size: 477 Bytes

Contents

module CodeRay
module Encoders
  
  # Returns the number of tokens.
  # 
  # Text and block tokens are counted.
  class Count < Encoder
    
    register_for :count
    
  protected
    
    def setup options
      @out = 0
    end
    
  public
    
    def text_token text, kind
      @out += 1
    end
    
    def begin_group kind
      @out += 1
    end
    alias end_group begin_group
    alias begin_line begin_group
    alias end_line begin_group
    
  end
  
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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