Methods

CodeRay::Encoders::LinesOfCode

Counts the LoC (Lines of Code). Returns an Integer >= 0.

Alias: loc

Everything that is not comment, markup, doctype/shebang, or an empty line, is considered to be code.

For example,

A Scanner class should define the token kinds that are not code in the KINDS_NOT_LOC constant, which defaults to [:comment, :doctype].

Constants

NON_EMPTY_LINE

Protected Instance Methods

finish(options) click to toggle source
    # File lib/coderay/encoders/lines_of_code.rb, line 38
38:     def finish options
39:       output @tokens.text.scan(NON_EMPTY_LINE).size
40:     end
setup(options) click to toggle source
    # File lib/coderay/encoders/lines_of_code.rb, line 25
25:     def setup options
26:       if scanner
27:         kinds_not_loc = scanner.class::KINDS_NOT_LOC
28:       else
29:         warn "Tokens have no associated scanner, counting all nonempty lines." if $VERBOSE
30:         kinds_not_loc = CodeRay::Scanners::Scanner::KINDS_NOT_LOC
31:       end
32:       
33:       options[:exclude] = kinds_not_loc
34:       
35:       super options
36:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.