Class: Applitools::EyesScreenshot

Inherits:
Object
  • Object
show all
Extended by:
Helpers, Forwardable
Defined in:
lib/applitools/core/eyes_screenshot.rb

Constant Summary collapse

COORDINATE_TYPES =
{
  context_as_is: 'CONTEXT_AS_IS',
  screenshot_as_is: 'SCREENSHOT_AS_IS',
  context_relative: 'CONTEXT_RELATIVE'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

abstract_attr_accessor, abstract_method, env_variable, environment_attribute, environment_variables

Constructor Details

#initialize(screenshot) ⇒ EyesScreenshot

Returns a new instance of EyesScreenshot.



18
19
20
21
# File 'lib/applitools/core/eyes_screenshot.rb', line 18

def initialize(screenshot)
  Applitools::ArgumentGuard.is_a? screenshot, 'screenshot', Applitools::Screenshot
  self.image = screenshot
end

Instance Attribute Details

#imageObject

Returns the value of attribute image.



9
10
11
# File 'lib/applitools/core/eyes_screenshot.rb', line 9

def image
  @image
end

#top_left_locationObject

Returns the value of attribute top_left_location.



9
10
11
# File 'lib/applitools/core/eyes_screenshot.rb', line 9

def top_left_location
  @top_left_location
end

Instance Method Details

#convert_region_location(region, from, to) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/applitools/core/eyes_screenshot.rb', line 35

def convert_region_location(region, from, to)
  Applitools::ArgumentGuard.not_nil region, 'region'
  Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region
  if region.empty?
    return region.dup.tap do |r|
      r.left = 0
      r.top = 0
      r.width = 0
      r.height = 0
    end
  end
  Applitools::ArgumentGuard.not_nil from, 'from'
  Applitools::ArgumentGuard.not_nil to, 'to'

  updated_location = convert_location(region.location, from, to)
  region.dup.tap do |r|
    r.left = updated_location.x
    r.top = updated_location.y
  end
end

#sub_screenshots(regions, coordinate_type) ⇒ Object



28
29
30
31
32
33
# File 'lib/applitools/core/eyes_screenshot.rb', line 28

def sub_screenshots(regions, coordinate_type)
  Applitools::ArgumentGuard.is_a? regions, 'regions', Enumerable
  regions.map do |region|
    sub_screenshot(region, coordinate_type, false, true)
  end
end