Class: CodeRay::Encoders::Statistic
- Defined in:
- lib/coderay/encoders/statistic.rb
Overview
Makes a statistic for the given tokens.
Alias: stats
Defined Under Namespace
Classes: TypeStats
Constant Summary
Constants inherited from Encoder
Instance Attribute Summary collapse
-
#real_token_count ⇒ Object
readonly
:nodoc:.
-
#type_stats ⇒ Object
readonly
:nodoc:.
Attributes inherited from Encoder
Attributes included from Plugin
Instance Method Summary collapse
- #begin_group(kind) ⇒ Object
- #begin_line(kind) ⇒ Object
- #block_token(action, kind) ⇒ Object
- #end_group(kind) ⇒ Object
- #end_line(kind) ⇒ Object
- #text_token(text, kind) ⇒ Object
Methods inherited from Encoder
#<<, const_missing, #encode, #encode_tokens, file_extension, #file_extension, #initialize, #token
Methods included from Plugin
#aliases, #plugin_host, #register_for, #title
Constructor Details
This class inherits a constructor from CodeRay::Encoders::Encoder
Instance Attribute Details
#real_token_count ⇒ Object (readonly)
:nodoc:
11 12 13 |
# File 'lib/coderay/encoders/statistic.rb', line 11 def real_token_count @real_token_count end |
#type_stats ⇒ Object (readonly)
:nodoc:
11 12 13 |
# File 'lib/coderay/encoders/statistic.rb', line 11 def type_stats @type_stats end |
Instance Method Details
#begin_group(kind) ⇒ Object
70 71 72 |
# File 'lib/coderay/encoders/statistic.rb', line 70 def begin_group kind block_token ':begin_group', kind end |
#begin_line(kind) ⇒ Object
78 79 80 |
# File 'lib/coderay/encoders/statistic.rb', line 78 def begin_line kind block_token ':begin_line', kind end |
#block_token(action, kind) ⇒ Object
86 87 88 89 90 |
# File 'lib/coderay/encoders/statistic.rb', line 86 def block_token action, kind @type_stats['TOTAL'].count += 1 @type_stats[action].count += 1 @type_stats[kind].count += 1 end |
#end_group(kind) ⇒ Object
74 75 76 |
# File 'lib/coderay/encoders/statistic.rb', line 74 def end_group kind block_token ':end_group', kind end |
#end_line(kind) ⇒ Object
82 83 84 |
# File 'lib/coderay/encoders/statistic.rb', line 82 def end_line kind block_token ':end_line', kind end |
#text_token(text, kind) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/coderay/encoders/statistic.rb', line 62 def text_token text, kind @real_token_count += 1 unless kind == :space @type_stats[kind].count += 1 @type_stats[kind].size += text.size @type_stats['TOTAL'].size += text.size @type_stats['TOTAL'].count += 1 end |