CoveredSourceCoveredRatio

module Ratio

Computes common coverage ratios from executed and executable line counts.

Definitions

def ratio

The fraction of executable lines that were executed.

Signature

returns Rational | Float

The executed-to-executable line ratio, or 1.0 when there are no executable lines.

Implementation

def ratio
	return 1.0 if executable_count.zero?
	
	Rational(executed_count, executable_count)
end

def complete?

Whether all executable lines were executed.

Signature

returns Boolean

Whether executed_count equals executable_count.

Implementation

def complete?
	executed_count == executable_count
end

def percentage

The coverage ratio as a percentage.

Signature

returns Numeric

The coverage ratio multiplied by 100.

Implementation

def percentage
	ratio * 100
end