Mercurial > hg > soundsoftware-site
comparison vendor/gems/coderay-1.0.0/lib/coderay/encoders/count.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
1 module CodeRay | |
2 module Encoders | |
3 | |
4 # Returns the number of tokens. | |
5 # | |
6 # Text and block tokens are counted. | |
7 class Count < Encoder | |
8 | |
9 register_for :count | |
10 | |
11 protected | |
12 | |
13 def setup options | |
14 super | |
15 | |
16 @count = 0 | |
17 end | |
18 | |
19 def finish options | |
20 output @count | |
21 end | |
22 | |
23 public | |
24 | |
25 def text_token text, kind | |
26 @count += 1 | |
27 end | |
28 | |
29 def begin_group kind | |
30 @count += 1 | |
31 end | |
32 alias end_group begin_group | |
33 alias begin_line begin_group | |
34 alias end_line begin_group | |
35 | |
36 end | |
37 | |
38 end | |
39 end |