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

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hitsObject

Returns the value of attribute hits

Returns:

  • (Object)

    the current value of hits



7
8
9
# File 'lib/minitest/subjective/file_result/branch_statistics/branch_hits.rb', line 7

def hits
  @hits
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



7
8
9
# File 'lib/minitest/subjective/file_result/branch_statistics/branch_hits.rb', line 7

def id
  @id
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



7
8
9
# File 'lib/minitest/subjective/file_result/branch_statistics/branch_hits.rb', line 7

def label
  @label
end

#rangeObject

Returns the value of attribute range

Returns:

  • (Object)

    the current value of range



7
8
9
# File 'lib/minitest/subjective/file_result/branch_statistics/branch_hits.rb', line 7

def range
  @range
end

Class Method Details

.from_pair(key, hits) ⇒ Object



12
13
14
15
# File 'lib/minitest/subjective/file_result/branch_statistics/branch_hits.rb', line 12

def self.from_pair(key, hits)
  label, id, *range = key
  new(label:, id:, range: Range.from_array(range), hits:)
end

Instance Method Details

#+(other) ⇒ Object



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

def +(other)
  return self unless matches?(other)

  self.class.new(label, id, range, hits + other.hits)
end

#-(other) ⇒ Object



23
24
25
26
27
# File 'lib/minitest/subjective/file_result/branch_statistics/branch_hits.rb', line 23

def -(other)
  return self unless matches?(other)

  self.class.new(label, id, range, hits - other.hits)
end

#covered?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/minitest/subjective/file_result/branch_statistics/branch_hits.rb', line 29

def covered?
  hits.positive?
end