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

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Formatting
Defined in:
lib/minitest/subjective/file_result/line_statistics.rb,
lib/minitest/subjective/file_result/line_statistics/line_hits.rb,
lib/minitest/subjective/file_result/line_statistics/formatting.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Formatting Classes: LineHits

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Formatting

#format

Constructor Details

#initialize(lines = []) ⇒ LineStatistics

Returns a new instance of LineStatistics.



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

def initialize(lines = [])
  @lines = lines.to_h { [_1.line, _1] }
end

Instance Attribute Details

#linesObject

Returns the value of attribute lines.



15
16
17
# File 'lib/minitest/subjective/file_result/line_statistics.rb', line 15

def lines
  @lines
end

Class Method Details

.from_hash(lines, branches:) ⇒ Object



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

def self.from_hash(lines, branches:)
  new(lines.filter_map.with_index { |value, key| value && LineHits.from_pair(key + 1, value, branches:) })
end

Instance Method Details

#+(other) ⇒ Object



27
28
29
30
31
# File 'lib/minitest/subjective/file_result/line_statistics.rb', line 27

def +(other)
  return self unless other

  self.class.new(lines.values.zip(other.lines.values).collect { |current, new| current + new })
end

#-(other) ⇒ Object



33
34
35
36
37
# File 'lib/minitest/subjective/file_result/line_statistics.rb', line 33

def -(other)
  return self unless other

  self.class.new(lines.values.zip(other.lines.values).collect { |current, new| current - new })
end

#==(other) ⇒ Object



47
48
49
# File 'lib/minitest/subjective/file_result/line_statistics.rb', line 47

def ==(other)
  other && lines == other.lines && branches == other.branches
end

#covered?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/minitest/subjective/file_result/line_statistics.rb', line 43

def covered?
  lines.values.all?(&:covered?)
end

#max_hitsObject



39
40
41
# File 'lib/minitest/subjective/file_result/line_statistics.rb', line 39

def max_hits
  lines.values.collect(&:hits).max
end