Class: Applitools::Selenium::FixedCutProvider
- Inherits:
-
Object
- Object
- Applitools::Selenium::FixedCutProvider
- Defined in:
- lib/applitools/selenium/fixed_cut_provider.rb
Class Method Summary collapse
Instance Method Summary collapse
- #cut(image) ⇒ Object
-
#initialize(left, header, right, footer) ⇒ FixedCutProvider
constructor
A new instance of FixedCutProvider.
Constructor Details
#initialize(left, header, right, footer) ⇒ FixedCutProvider
Returns a new instance of FixedCutProvider.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/applitools/selenium/fixed_cut_provider.rb', line 26 def initialize(left, header, right, ) Applitools::ArgumentGuard.is_a?(left, 'left', Integer) Applitools::ArgumentGuard.is_a?(header, 'header', Integer) Applitools::ArgumentGuard.is_a?(right, 'right', Integer) Applitools::ArgumentGuard.is_a?(, 'footer', Integer) self.left = left self.header = header self.right = right self. = end |
Class Method Details
.viewport(image, viewport_size, region_to_check) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/applitools/selenium/fixed_cut_provider.rb', line 7 def (image, , region_to_check) return nil if image.square == .square current_scroll_position = region_to_check.scroll_position_provider.current_position image_canvas = Applitools::Region.new(0, 0, image.width, image.height) = image_canvas.dup.intersect( Applitools::Region.from_location_size( Applitools::Location.new(current_scroll_position.left, current_scroll_position.top), ) ) new( .left, .top, image_canvas.right - .right, image_canvas.bottom - .bottom ) end |
Instance Method Details
#cut(image) ⇒ Object
37 38 39 40 41 |
# File 'lib/applitools/selenium/fixed_cut_provider.rb', line 37 def cut(image) crop_width = image.width - left - right crop_height = image.height - header - image.crop!(left, header, crop_width, crop_height) end |