Class: Covered::Statistics

Inherits:
Wrapper show all
Includes:
Ratio
Defined in:
lib/covered/statistics.rb

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#output

Instance Method Summary collapse

Methods included from Ratio

#complete?, #percentage, #ratio

Methods inherited from Wrapper

#accept?, #disable, #each, #enable, #expand_path, #mark, #relative_path, #to_h

Methods inherited from Base

#accept?, #disable, #each, #enable, #expand_path, #mark, #relative_path

Constructor Details

#initializeStatistics

Returns a new instance of Statistics.



26
27
28
29
30
# File 'lib/covered/statistics.rb', line 26

def initialize
	@count = 0
	@executable_count = 0
	@executed_count = 0
end

Instance Attribute Details

#countObject (readonly)

Total number of files added.



33
34
35
# File 'lib/covered/statistics.rb', line 33

def count
  @count
end

#executable_countObject (readonly)

The number of lines which could have been executed.



36
37
38
# File 'lib/covered/statistics.rb', line 36

def executable_count
  @executable_count
end

#executed_countObject (readonly)

The number of lines that were executed.



39
40
41
# File 'lib/covered/statistics.rb', line 39

def executed_count
  @executed_count
end

Instance Method Details

#<<(coverage) ⇒ Object



41
42
43
44
45
# File 'lib/covered/statistics.rb', line 41

def << coverage
	@count += 1
	@executable_count += coverage.executable_count
	@executed_count += coverage.executed_count
end


49
50
51
52
53
# File 'lib/covered/statistics.rb', line 49

def print(output)
	output.puts "* #{count} files checked; #{executed_count}/#{executable_count} lines executed; #{percentage.to_f.round(2)}% covered."
	
	# Could output funny message here, especially for 100% coverage.
end