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.



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

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

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



3
4
5
# File 'lib/dotdiff/comparer.rb', line 3

def element
  @element
end

#pageObject (readonly)

Returns the value of attribute page.



3
4
5
# File 'lib/dotdiff/comparer.rb', line 3

def page
  @page
end

#snapshotObject (readonly)

Returns the value of attribute snapshot.



3
4
5
# File 'lib/dotdiff/comparer.rb', line 3

def snapshot
  @snapshot
end

Instance Method Details

#resultObject



11
12
13
14
15
16
17
18
19
# File 'lib/dotdiff/comparer.rb', line 11

def result
  if element.is_a?(Capybara::Session)
    compare_page
  elsif element.is_a?(Capybara::Node::Base)
    compare_element
  else
    raise ArgumentError, "Unknown element class received: #{element.class.name}"
  end
end