Class: Minitest::Subjective::FileResult::BranchStatistics

Inherits:
Object
  • Object
show all
Includes:
Formatting
Defined in:
lib/minitest/subjective/file_result/branch_statistics.rb,
lib/minitest/subjective/file_result/branch_statistics/formatting.rb,
lib/minitest/subjective/file_result/branch_statistics/branch_hits.rb,
lib/minitest/subjective/file_result/branch_statistics/conditional_hits.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Formatting Classes: BranchHits, ConditionalHits

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Formatting

#format

Constructor Details

#initialize(branches) ⇒ BranchStatistics

Returns a new instance of BranchStatistics.



21
22
23
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 21

def initialize(branches)
  @branches = branches
end

Instance Attribute Details

#branchesObject

Returns the value of attribute branches.



15
16
17
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 15

def branches
  @branches
end

Class Method Details

.from_hash(branches) ⇒ Object



17
18
19
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 17

def self.from_hash(branches)
  new(branches.collect { |key, value| ConditionalHits.from_pair(key, value) })
end

Instance Method Details

#+(other) ⇒ Object



25
26
27
28
29
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 25

def +(other)
  return self unless other

  self.class.new(branches.zip(other.branches).collect { |current, new| current + new })
end

#-(other) ⇒ Object



31
32
33
34
35
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 31

def -(other)
  return self unless other

  self.class.new(branches.zip(other.branches).collect { |current, new| current - new })
end

#==(other) ⇒ Object



49
50
51
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 49

def ==(other)
  other && branches == other.branches
end

#[](index) ⇒ Object



37
38
39
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 37

def [](index)
  branches.filter { _1.cover?(index) }
end

#covered?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 45

def covered?
  branches.all?(&:covered?)
end

#filterObject



41
42
43
# File 'lib/minitest/subjective/file_result/branch_statistics.rb', line 41

def filter(&)
  self.class.new(branches.filter(&))
end