Class: MyHashDiff

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

Overview

A ruby gem that will implement the diff algorithm on hash

Class Method Summary collapse

Class Method Details

.calculate(left, right) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/my_hash_diff.rb', line 5

def self.calculate(left, right)
  right.each do |k, v|
    next if left[k].nil?

    if left[k] == v
      left.delete(k)
    else
      left[k] -= v
    end
  end
  left
end