Class: Applitools::Images::Target
- Inherits:
-
Object
- Object
- Applitools::Images::Target
- Includes:
- FluentInterface
- Defined in:
- lib/applitools/images/target.rb
Instance Attribute Summary collapse
-
#accessibility_regions ⇒ Object
Returns the value of attribute accessibility_regions.
-
#floating_regions ⇒ Object
Returns the value of attribute floating_regions.
-
#ignored_regions ⇒ Object
Returns the value of attribute ignored_regions.
-
#image ⇒ Object
Returns the value of attribute image.
-
#options ⇒ Object
Returns the value of attribute options.
-
#region_to_check ⇒ Object
Returns the value of attribute region_to_check.
Class Method Summary collapse
- .any(screenshot) ⇒ Object
- .blob(blob_image) ⇒ Object
- .image(image) ⇒ Object
- .path(path) ⇒ Object
- .screenshot(screenshot) ⇒ Object
Instance Method Summary collapse
- #accesibility(*args) ⇒ Object
- #floating(*args) ⇒ Object
- #ignore(*args) ⇒ Object
-
#initialize(image) ⇒ Target
constructor
A new instance of Target.
- #region(region = nil) ⇒ Object
Constructor Details
#initialize(image) ⇒ Target
Returns a new instance of Target.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/applitools/images/target.rb', line 50 def initialize(image) Applitools::ArgumentGuard.not_nil(image, 'image') Applitools::ArgumentGuard.is_a? image, 'image', Applitools::Screenshot self.image = image self.ignored_regions = [] self.floating_regions = [] self. = { trim: false } end |
Instance Attribute Details
#accessibility_regions ⇒ Object
Returns the value of attribute accessibility_regions.
48 49 50 |
# File 'lib/applitools/images/target.rb', line 48 def accessibility_regions @accessibility_regions end |
#floating_regions ⇒ Object
Returns the value of attribute floating_regions.
48 49 50 |
# File 'lib/applitools/images/target.rb', line 48 def floating_regions @floating_regions end |
#ignored_regions ⇒ Object
Returns the value of attribute ignored_regions.
48 49 50 |
# File 'lib/applitools/images/target.rb', line 48 def ignored_regions @ignored_regions end |
#image ⇒ Object
Returns the value of attribute image.
48 49 50 |
# File 'lib/applitools/images/target.rb', line 48 def image @image end |
#options ⇒ Object
Returns the value of attribute options.
48 49 50 |
# File 'lib/applitools/images/target.rb', line 48 def @options end |
#region_to_check ⇒ Object
Returns the value of attribute region_to_check.
48 49 50 |
# File 'lib/applitools/images/target.rb', line 48 def region_to_check @region_to_check end |
Class Method Details
.any(screenshot) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/applitools/images/target.rb', line 30 def any(screenshot) case screenshot when Applitools::Screenshot screenshot(screenshot) when ChunkyPNG::Image image(screenshot) when String begin blob(screenshot) rescue ChunkyPNG::SignatureMismatch path(screenshot) end else raise Applitools::EyesIllegalArgument.new "Passed screenshot is not image type (#{screenshot.class})" end end |
.blob(blob_image) ⇒ Object
12 13 14 15 16 |
# File 'lib/applitools/images/target.rb', line 12 def blob(blob_image) Applitools::ArgumentGuard.not_nil blob_image, 'blob_image' Applitools::ArgumentGuard.is_a? blob_image, 'blob_image', String new Applitools::Screenshot.from_datastream(blob_image) end |
.image(image) ⇒ Object
18 19 20 21 22 |
# File 'lib/applitools/images/target.rb', line 18 def image(image) Applitools::ArgumentGuard.not_nil image, 'image' Applitools::ArgumentGuard.is_a? image, 'image', ChunkyPNG::Image new Applitools::Screenshot.from_image(image) end |
.path(path) ⇒ Object
7 8 9 10 |
# File 'lib/applitools/images/target.rb', line 7 def path(path) raise Applitools::EyesIllegalArgument unless File.exist?(path) new Applitools::Screenshot.from_image(ChunkyPNG::Image.from_file(path)) end |
.screenshot(screenshot) ⇒ Object
24 25 26 27 28 |
# File 'lib/applitools/images/target.rb', line 24 def screenshot(screenshot) Applitools::ArgumentGuard.not_nil screenshot, 'screenshot' Applitools::ArgumentGuard.is_a? screenshot, 'screenshot', Applitools::Screenshot new screenshot end |
Instance Method Details
#accesibility(*args) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/applitools/images/target.rb', line 109 def accesibility(*args) accessibility_regions << case args.first when Applitools::AccessibilityRegion args.first when Applitools::Region Applitools::AccessibilityRegion.new(args.first, args.last) else accessibility_region_type = args.pop region = Applitools::Region.new(*args) Applitools::AccessibilityRegion.new(region, accessibility_region_type) end end |
#floating(*args) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/applitools/images/target.rb', line 77 def floating(*args) requested_padding = if args.last.is_a? Applitools::PaddingBounds args.pop else Applitools::PaddingBounds::PIXEL_PADDING end value = case args.first when Applitools::FloatingRegion proc { args.first.padding(requested_padding) } when Applitools::Region proc do region = args.shift Applitools::FloatingRegion.any(region, *args).padding(requested_padding) end else self.floating_regions = [] end floating_regions << value self end |
#ignore(*args) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/applitools/images/target.rb', line 61 def ignore(*args) requested_padding = if args.last.is_a? Applitools::PaddingBounds args.pop else Applitools::PaddingBounds::PIXEL_PADDING end region = args.shift if region Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region ignored_regions << region.padding(requested_padding) else self.ignored_regions = [] end self end |
#region(region = nil) ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/applitools/images/target.rb', line 99 def region(region = nil) if region Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region self.region_to_check = region else self.region_to_check = nil end self end |