Class: DotDiff::Snapshot
- Inherits:
-
Object
- Object
- DotDiff::Snapshot
- Includes:
- Image::Cropper
- Defined in:
- lib/dotdiff/snapshot.rb
Constant Summary collapse
- IMAGE_EXT =
'png'.freeze
Instance Attribute Summary collapse
-
#base_filename(with_extention = true) ⇒ Object
readonly
Returns the value of attribute base_filename.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#rootdir ⇒ Object
readonly
Returns the value of attribute rootdir.
-
#subdir ⇒ Object
readonly
Returns the value of attribute subdir.
Instance Method Summary collapse
- #basefile ⇒ Object
- #capture_from_browser(hide_and_show = true, element_handler = ElementHandler.new(page)) ⇒ Object
- #cropped_file ⇒ Object
- #fullscreen_file ⇒ Object
-
#initialize(options = {}) ⇒ Snapshot
constructor
A new instance of Snapshot.
- #resave_cropped_file ⇒ Object
- #resave_fullscreen_file ⇒ Object
Methods included from Image::Cropper
#crop_and_resave, #height, #load_image, #width
Constructor Details
#initialize(options = {}) ⇒ Snapshot
Returns a new instance of Snapshot.
9 10 11 12 13 14 15 |
# File 'lib/dotdiff/snapshot.rb', line 9 def initialize( = {}) opts = { rootdir: DotDiff.image_store_path }.merge(Hash()) @base_filename = opts[:filename] @subdir = opts[:subdir].to_s @rootdir = opts[:rootdir].to_s @page = opts[:page] end |
Instance Attribute Details
#base_filename(with_extention = true) ⇒ Object (readonly)
Returns the value of attribute base_filename.
5 6 7 |
# File 'lib/dotdiff/snapshot.rb', line 5 def base_filename @base_filename end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/dotdiff/snapshot.rb', line 5 def page @page end |
#rootdir ⇒ Object (readonly)
Returns the value of attribute rootdir.
5 6 7 |
# File 'lib/dotdiff/snapshot.rb', line 5 def rootdir @rootdir end |
#subdir ⇒ Object (readonly)
Returns the value of attribute subdir.
5 6 7 |
# File 'lib/dotdiff/snapshot.rb', line 5 def subdir @subdir end |
Instance Method Details
#basefile ⇒ Object
25 26 27 |
# File 'lib/dotdiff/snapshot.rb', line 25 def basefile File.join(rootdir, subdir.to_s, base_filename) end |
#capture_from_browser(hide_and_show = true, element_handler = ElementHandler.new(page)) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/dotdiff/snapshot.rb', line 43 def capture_from_browser(hide_and_show = true, element_handler = ElementHandler.new(page)) if hide_and_show element_handler.hide page.save_screenshot(fullscreen_file) element_handler.show else page.save_screenshot(fullscreen_file) end end |
#cropped_file ⇒ Object
21 22 23 |
# File 'lib/dotdiff/snapshot.rb', line 21 def cropped_file @cropped ||= File.join(Dir.tmpdir, subdir, "#{base_filename(false)}_cropped.#{IMAGE_EXT}") end |
#fullscreen_file ⇒ Object
17 18 19 |
# File 'lib/dotdiff/snapshot.rb', line 17 def fullscreen_file @fullscreen ||= File.join(Dir.tmpdir, subdir, base_filename) end |
#resave_cropped_file ⇒ Object
53 54 55 |
# File 'lib/dotdiff/snapshot.rb', line 53 def resave_cropped_file resave_base_file(:cropped) end |
#resave_fullscreen_file ⇒ Object
57 58 59 |
# File 'lib/dotdiff/snapshot.rb', line 57 def resave_fullscreen_file resave_base_file(:fullscreen) end |