Class: Minitest::Subjective::FileResult::MethodStatistics
- Inherits:
-
Object
- Object
- Minitest::Subjective::FileResult::MethodStatistics
show all
- Includes:
- Formatting
- Defined in:
- lib/minitest/subjective/file_result/method_statistics.rb,
lib/minitest/subjective/file_result/method_statistics/formatting.rb,
lib/minitest/subjective/file_result/method_statistics/method_hits.rb
Overview
Defined Under Namespace
Modules: Formatting
Classes: MethodHits
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Formatting
#format
Constructor Details
Returns a new instance of MethodStatistics.
20
21
22
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 20
def initialize(methods)
@method_hits = methods
end
|
Instance Attribute Details
#method_hits ⇒ Object
Returns the value of attribute method_hits.
14
15
16
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 14
def method_hits
@method_hits
end
|
Class Method Details
.from_hash(methods, branches:) ⇒ Object
16
17
18
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 16
def self.from_hash(methods, branches:)
new(methods.collect { |key, value| MethodHits.from_pair(key, value, branches:) })
end
|
Instance Method Details
#+(other) ⇒ Object
24
25
26
27
28
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 24
def +(other)
return self unless other
self.class.new(method_hits.zip(other.method_hits).collect { |current, new| current + new })
end
|
#-(other) ⇒ Object
30
31
32
33
34
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 30
def -(other)
return self unless other
self.class.new(method_hits.zip(other.method_hits).collect { |current, new| current - new })
end
|
#==(other) ⇒ Object
56
57
58
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 56
def ==(other)
other && method_hits == other.method_hits && branches == other.branches
end
|
#[](index) ⇒ Object
44
45
46
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 44
def [](index)
method_hits.find { _1.cover?(index) } if index
end
|
#covered? ⇒ Boolean
52
53
54
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 52
def covered?
method_hits.all?(&:covered?)
end
|
#find_by(**options) ⇒ Object
36
37
38
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 36
def find_by(**options)
method_hits.find { |method| options.all? { |key, value| method.send(key) == value } }
end
|
#find_by_index(index) ⇒ Object
48
49
50
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 48
def find_by_index(index)
method_hits.find { _1.starts_at?(index) } if index
end
|
#max_hits ⇒ Object
40
41
42
|
# File 'lib/minitest/subjective/file_result/method_statistics.rb', line 40
def max_hits
method_hits.collect(&:hits).max
end
|