class DeepCover::Analyser::StatsBase

Constants

DECIMALS
VALUES

Public Class Methods

new(executed: 0, not_executed: 0, not_executable: 0, ignored: 0) click to toggle source
# File lib/deep_cover/analyser/stats.rb, line 17
def initialize(executed: 0, not_executed: 0, not_executable: 0, ignored: 0)
  @executed = executed
  @not_executed = not_executed
  @not_executable = not_executable
  @ignored = ignored
  freeze
end

Public Instance Methods

+(other) click to toggle source
# File lib/deep_cover/analyser/stats.rb, line 25
def +(other)
  self.class.new(**to_h.merge(other.to_h) { |k, a, b| a + b })
end
percent_covered() click to toggle source
# File lib/deep_cover/analyser/stats.rb, line 41
def percent_covered
  return 100 if potentially_executable == 0
  (100 * (1 - not_executed.fdiv(potentially_executable))).round(DECIMALS)
end
potentially_executable() click to toggle source
# File lib/deep_cover/analyser/stats.rb, line 37
def potentially_executable
  total - not_executable
end
to_h() click to toggle source
# File lib/deep_cover/analyser/stats.rb, line 13
def to_h
  VALUES.map { |val| [val, public_send(val)] }.to_h
end
total() click to toggle source
# File lib/deep_cover/analyser/stats.rb, line 29
def total
  to_h.values.inject(:+)
end
with(**values) click to toggle source
# File lib/deep_cover/analyser/stats.rb, line 33
def with(**values)
  self.class.new(**to_h.merge(values))
end