Class: Applitools::Images::Target
- Inherits:
-
Object
- Object
- Applitools::Images::Target
- Defined in:
- lib/applitools/images/target.rb
Instance Attribute Summary collapse
-
#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
- #ignore(region = nil) ⇒ Object
-
#initialize(image) ⇒ Target
constructor
A new instance of Target.
- #region(region = nil) ⇒ Object
- #timeout(value = nil) ⇒ Object
- #trim(value = true) ⇒ Object
Constructor Details
#initialize(image) ⇒ Target
Returns a new instance of Target.
47 48 49 50 51 52 53 54 55 |
# File 'lib/applitools/images/target.rb', line 47 def initialize(image) Applitools::ArgumentGuard.not_nil(image, 'image') Applitools::ArgumentGuard.is_a? image, 'image', Applitools::Screenshot self.image = image self.ignored_regions = [] self. = { trim: false } end |
Instance Attribute Details
#ignored_regions ⇒ Object
Returns the value of attribute ignored_regions.
45 46 47 |
# File 'lib/applitools/images/target.rb', line 45 def ignored_regions @ignored_regions end |
#image ⇒ Object
Returns the value of attribute image.
45 46 47 |
# File 'lib/applitools/images/target.rb', line 45 def image @image end |
#options ⇒ Object
Returns the value of attribute options.
45 46 47 |
# File 'lib/applitools/images/target.rb', line 45 def @options end |
#region_to_check ⇒ Object
Returns the value of attribute region_to_check.
45 46 47 |
# File 'lib/applitools/images/target.rb', line 45 def region_to_check @region_to_check end |
Class Method Details
.any(screenshot) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/applitools/images/target.rb', line 27 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
9 10 11 12 13 |
# File 'lib/applitools/images/target.rb', line 9 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
15 16 17 18 19 |
# File 'lib/applitools/images/target.rb', line 15 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
4 5 6 7 |
# File 'lib/applitools/images/target.rb', line 4 def path(path) raise Applitools::EyesIllegalArgument unless File.exist?(path) new Applitools::Screenshot.from_image(ChunkyPNG::Image.from_file(path)) end |
.screenshot(screenshot) ⇒ Object
21 22 23 24 25 |
# File 'lib/applitools/images/target.rb', line 21 def screenshot(screenshot) Applitools::ArgumentGuard.not_nil screenshot, 'screenshot' Applitools::ArgumentGuard.is_a? screenshot, 'screenshot', Applitools::Screenshot new screenshot end |
Instance Method Details
#ignore(region = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/applitools/images/target.rb', line 57 def ignore(region = nil) if region Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region ignored_regions << region else self.ignored_regions = [] end self end |
#region(region = nil) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/applitools/images/target.rb', line 67 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 |
#timeout(value = nil) ⇒ Object
82 83 84 85 |
# File 'lib/applitools/images/target.rb', line 82 def timeout(value = nil) [:timeout] = value ? value : nil self end |
#trim(value = true) ⇒ Object
77 78 79 80 |
# File 'lib/applitools/images/target.rb', line 77 def trim(value = true) [:trim] = value ? true : false self end |