Class: PmdTester::RunningDiffCounters

Inherits:
Object
  • Object
show all
Defined in:
lib/pmdtester/report_diff.rb

Overview

A bunch of counters to summarize differences

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_total) ⇒ RunningDiffCounters

Returns a new instance of RunningDiffCounters.



8
9
10
11
12
13
# File 'lib/pmdtester/report_diff.rb', line 8

def initialize(base_total)
  @base_total = base_total
  @patch_total = 0

  @new = @removed = @changed = 0
end

Instance Attribute Details

#base_totalObject

Returns the value of attribute base_total.



6
7
8
# File 'lib/pmdtester/report_diff.rb', line 6

def base_total
  @base_total
end

#changedObject

Returns the value of attribute changed.



6
7
8
# File 'lib/pmdtester/report_diff.rb', line 6

def changed
  @changed
end

#newObject

Returns the value of attribute new.



6
7
8
# File 'lib/pmdtester/report_diff.rb', line 6

def new
  @new
end

#patch_totalObject

Returns the value of attribute patch_total.



6
7
8
# File 'lib/pmdtester/report_diff.rb', line 6

def patch_total
  @patch_total
end

#removedObject

Returns the value of attribute removed.



6
7
8
# File 'lib/pmdtester/report_diff.rb', line 6

def removed
  @removed
end

Instance Method Details

#changed_totalObject



15
16
17
# File 'lib/pmdtester/report_diff.rb', line 15

def changed_total
  new + removed + changed
end

#merge!(other) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/pmdtester/report_diff.rb', line 19

def merge!(other)
  self.changed += other.changed
  self.new += other.new
  self.removed += other.removed
  self.base_total += other.base_total
  self.patch_total += other.patch_total
end

#to_hObject



27
28
29
30
31
32
33
34
35
# File 'lib/pmdtester/report_diff.rb', line 27

def to_h
  {
    changed: changed,
    new: new,
    removed: removed,
    base_total: base_total,
    patch_total: patch_total
  }
end

#to_sObject



37
38
39
# File 'lib/pmdtester/report_diff.rb', line 37

def to_s
  "RunningDiffCounters[#{to_h}]"
end