Class: Capybara::Screenshot::Diff::Drivers::BaseDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/screenshot/diff/drivers/base_driver.rb

Direct Known Subclasses

ChunkyPNGDriver, VipsDriver

Constant Summary collapse

PNG_EXTENSION =
".png"

Instance Method Summary collapse

Instance Method Details

#dimension(image) ⇒ Object



30
31
32
# File 'lib/capybara/screenshot/diff/drivers/base_driver.rb', line 30

def dimension(image)
  [width_for(image), height_for(image)]
end

#height_for(image) ⇒ Object



18
19
20
# File 'lib/capybara/screenshot/diff/drivers/base_driver.rb', line 18

def height_for(image)
  image.height
end

#image_area_size(image) ⇒ Object



26
27
28
# File 'lib/capybara/screenshot/diff/drivers/base_driver.rb', line 26

def image_area_size(image)
  width_for(image) * height_for(image)
end

#same_dimension?(comparison) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/capybara/screenshot/diff/drivers/base_driver.rb', line 14

def same_dimension?(comparison)
  dimension(comparison.base_image) == dimension(comparison.new_image)
end

#width_for(image) ⇒ Object



22
23
24
# File 'lib/capybara/screenshot/diff/drivers/base_driver.rb', line 22

def width_for(image)
  image.width
end