Module: Super::Stupid::Diff::ClassMethods

Defined in:
lib/ssdiff.rb

Instance Method Summary collapse

Instance Method Details

#ssdiff(a, b) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ssdiff.rb', line 7

def ssdiff(a, b)
  return [] if a == b
  return [a, b] unless a.instance_of?(b.class)

  convert_to_hash = false

  if a.instance_of?(String)
    a = a.split
    b = b.split
  end

  if a.instance_of?(Hash)
    a = a.to_a
    b = b.to_a
    convert_to_hash = true
  end

  ((a - b) + (b -a))
end