Class: Minitest::Subjective::FileResult::LineStatistics::LineHits

Inherits:
Struct
  • Object
show all
Defined in:
lib/minitest/subjective/file_result/line_statistics/line_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/line_statistics/line_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/line_statistics/line_hits.rb', line 7

def hits
  @hits
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



7
8
9
# File 'lib/minitest/subjective/file_result/line_statistics/line_hits.rb', line 7

def line
  @line
end

Class Method Details

.from_pair(line, hits, branches: nil) ⇒ Object



8
9
10
# File 'lib/minitest/subjective/file_result/line_statistics/line_hits.rb', line 8

def self.from_pair(line, hits, branches: nil)
  new(line:, hits:, branches:)
end

Instance Method Details

#+(other) ⇒ Object



12
13
14
15
16
# File 'lib/minitest/subjective/file_result/line_statistics/line_hits.rb', line 12

def +(other)
  return self unless other && other.line == line

  self.class.new(line, hits + other.hits, branches && (branches + other.branches))
end

#-(other) ⇒ Object



18
19
20
21
22
# File 'lib/minitest/subjective/file_result/line_statistics/line_hits.rb', line 18

def -(other)
  return self unless other && other.line == line

  self.class.new(line, hits - other.hits, branches && (branches - other.branches))
end

#covered?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/minitest/subjective/file_result/line_statistics/line_hits.rb', line 24

def covered?
  hits.positive? && (branches.nil? || branches.covered?)
end