Module: SimpleCov::ArrayMergeHelper

Defined in:
lib/simplecov/merge_helpers.rb

Instance Method Summary collapse

Instance Method Details

#merge_resultset(array) ⇒ Object

Merges an array of coverage results with self


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/simplecov/merge_helpers.rb', line 3

def merge_resultset(array)
  new_array = []

  self.each_with_index do |element, i|
    new_array[i] = element
  end

  array.each_with_index do |element, i|
    if element.nil? and new_array[i].nil?
      new_array[i] = nil
    else
      local_value = element || 0
      other_value = new_array[i] || 0
      new_array[i] = local_value + other_value
    end
  end
  new_array
end