diff options
Diffstat (limited to 'lib/coderay/encoders/lines_of_code.rb')
-rw-r--r-- | lib/coderay/encoders/lines_of_code.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/coderay/encoders/lines_of_code.rb b/lib/coderay/encoders/lines_of_code.rb new file mode 100644 index 0000000..8ffe9dc --- /dev/null +++ b/lib/coderay/encoders/lines_of_code.rb @@ -0,0 +1,19 @@ +module CodeRay +module Encoders + + class LinesOfCode < Encoder + + register_for :lines_of_code + + def compile tokens, options + @loc = tokens.token_class_filter(:exclude => [:comment, :doctype]).text.scan(/^\s*\S.*$/).size + end + + def finish options + @loc + end + + end + +end +end |