Included Modules

Files

Class Index [+]

Quicksearch

CodeRay::Encoders::Statistic

Makes a statistic for the given tokens.

Constants

TypeStats
STATS
TOKEN_TYPES_ROW

space 12007 33.81 % 1.7

Attributes

type_stats[R]
real_token_count[R]

Protected Instance Methods

block_token(action, kind) click to toggle source

TODO Hierarchy handling

    # File lib/coderay/encoders/statistic.rb, line 35
35:     def block_token action, kind
36:       @type_stats['TOTAL'].count += 1
37:       @type_stats['open/close'].count += 1
38:     end
finish(options) click to toggle source
    # File lib/coderay/encoders/statistic.rb, line 58
58:     def finish options
59:       all = @type_stats['TOTAL']
60:       all_count, all_size = all.count, all.size
61:       @type_stats.each do |type, stat|
62:         stat.size /= stat.count.to_f
63:       end
64:       types_stats = @type_stats.sort_by { |k, v| [-v.count, k.to_s] }.map do |k, v|
65:         TOKEN_TYPES_ROW % [k, v.count, 100.0 * v.count / all_count, v.size]
66:       end.join
67:       STATS % [
68:         all_count, @real_token_count, all_size,
69:         @type_stats.delete_if { |k, v| k.is_a? String }.size,
70:         types_stats
71:       ]
72:     end
generate(tokens, options) click to toggle source
    # File lib/coderay/encoders/statistic.rb, line 21
21:     def generate tokens, options
22:       @tokens = tokens
23:       super
24:     end
setup(options) click to toggle source
    # File lib/coderay/encoders/statistic.rb, line 16
16:     def setup options
17:       @type_stats = Hash.new { |h, k| h[k] = TypeStats.new 0, 0 }
18:       @real_token_count = 0
19:     end
text_token(text, kind) click to toggle source
    # File lib/coderay/encoders/statistic.rb, line 26
26:     def text_token text, kind
27:       @real_token_count += 1 unless kind == :space
28:       @type_stats[kind].count += 1
29:       @type_stats[kind].size += text.size
30:       @type_stats['TOTAL'].size += text.size
31:       @type_stats['TOTAL'].count += 1
32:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.