Class: Minitest::Subjective::FileResult::MethodStatistics::MethodHits
- Inherits:
-
Struct
- Object
- Struct
- Minitest::Subjective::FileResult::MethodStatistics::MethodHits
- Extended by:
- Forwardable
- Defined in:
- lib/minitest/subjective/file_result/method_statistics/method_hits.rb
Instance Attribute Summary collapse
-
#branches ⇒ Object
Returns the value of attribute branches.
-
#hits ⇒ Object
Returns the value of attribute hits.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#name ⇒ Object
Returns the value of attribute name.
-
#range ⇒ Object
Returns the value of attribute range.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#branches ⇒ Object
Returns the value of attribute branches
7 8 9 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7 def branches @branches end |
#hits ⇒ Object
Returns the value of attribute hits
7 8 9 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7 def hits @hits end |
#klass ⇒ Object
Returns the value of attribute klass
7 8 9 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7 def klass @klass end |
#name ⇒ Object
Returns the value of attribute name
7 8 9 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7 def name @name end |
#range ⇒ Object
Returns the value of attribute range
7 8 9 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7 def range @range end |
Class Method Details
.from_pair(key, hits, branches: []) ⇒ Object
12 13 14 15 16 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 12 def self.from_pair(key, hits, branches: []) klass, name, *range = key range = Range.from_array(range) new(klass: klass.name, name:, range:, hits:, branches: branches.filter { range.cover?(_1.range) }) end |
Instance Method Details
#+(other) ⇒ Object
18 19 20 21 22 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 18 def +(other) return self unless other self.class.new(klass, name, range, hits + other.hits, branches && (branches + other.branches)) end |
#-(other) ⇒ Object
24 25 26 27 28 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 24 def -(other) return self unless other self.class.new(klass, name, range, hits - other.hits, branches && (branches - other.branches)) end |
#covered? ⇒ Boolean
30 31 32 |
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 30 def covered? hits.positive? && (branches.nil? || branches.covered?) end |