Class: Minitest::Subjective::FileResult::MethodStatistics::MethodHits

Inherits:
Struct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/minitest/subjective/file_result/method_statistics/method_hits.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#branchesObject

Returns the value of attribute branches

Returns:

  • (Object)

    the current value of branches



7
8
9
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7

def branches
  @branches
end

#hitsObject

Returns the value of attribute hits

Returns:

  • (Object)

    the current value of hits



7
8
9
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7

def hits
  @hits
end

#klassObject

Returns the value of attribute klass

Returns:

  • (Object)

    the current value of klass



7
8
9
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7

def klass
  @klass
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



7
8
9
# File 'lib/minitest/subjective/file_result/method_statistics/method_hits.rb', line 7

def name
  @name
end

#rangeObject

Returns the value of attribute range

Returns:

  • (Object)

    the current value of 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

Returns:

  • (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