Class: DotDiff::Comparer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, page, snapshot) ⇒ Comparer

Returns a new instance of Comparer.



7
8
9
10
11
# File 'lib/dotdiff/comparer.rb', line 7

def initialize(element, page, snapshot)
  @page = page
  @element = element
  @snapshot = snapshot
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



5
6
7
# File 'lib/dotdiff/comparer.rb', line 5

def element
  @element
end

#pageObject (readonly)

Returns the value of attribute page.



5
6
7
# File 'lib/dotdiff/comparer.rb', line 5

def page
  @page
end

#snapshotObject (readonly)

Returns the value of attribute snapshot.



5
6
7
# File 'lib/dotdiff/comparer.rb', line 5

def snapshot
  @snapshot
end

Instance Method Details

#resultObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dotdiff/comparer.rb', line 13

def result
  comparer = build_comparer

  if comparer.nil?
    raise ArgumentError, "Unknown element class received: #{element.class.name}"
  end

  passed, msg = comparer.run
  write_failure_imgs(comparer.new_image_path) if !passed && DotDiff.failure_image_path

  [passed, msg]
end