Class: LooksGood::ImageFromElement
- Defined in:
- lib/looks_good/image.rb
Instance Attribute Summary collapse
-
#image ⇒ Object
Returns the value of attribute image.
Attributes inherited from Image
Instance Method Summary collapse
-
#initialize(element, file_name) ⇒ ImageFromElement
constructor
A new instance of ImageFromElement.
- #verify_and_save ⇒ Object
Methods inherited from Image
Constructor Details
#initialize(element, file_name) ⇒ ImageFromElement
Returns a new instance of ImageFromElement.
34 35 36 37 38 |
# File 'lib/looks_good/image.rb', line 34 def initialize(element, file_name) super(image, file_name) @element = element @image = capture_image end |
Instance Attribute Details
#image ⇒ Object
Returns the value of attribute image.
32 33 34 |
# File 'lib/looks_good/image.rb', line 32 def image @image end |
Instance Method Details
#verify_and_save ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/looks_good/image.rb', line 40 def verify_and_save LooksGood::Configuration.max_no_tries.times do comparable = capture_image matches = LooksGood::Comparison.new(self,Image.new(comparable,@file_name)).matches? if matches self.save puts "Saved #{self.path} as reference" return() else @image = comparable end end raise 'Could not save a stable image. This could be due to animations or page load times. Saved a reference image, delete it to re-try' end |