Class: Dhalang::Screenshot
- Inherits:
-
Object
- Object
- Dhalang::Screenshot
- Defined in:
- lib/Screenshot.rb
Overview
Allows consumers of this library to take screenshots with Puppeteer.
Class Method Summary collapse
-
.get_from_url(url, image_type, options = {}) ⇒ String
Captures ascreenshot of the webpage under the given url.
-
.get_from_url_as_jpeg(url, options = {}) ⇒ String
DEPRECATED: Please use `get_from_url(url, :jpeg)` instead.
-
.get_from_url_as_png(url, options = {}) ⇒ String
DEPRECATED: Please use `get_from_url(url, :png)` instead.
Class Method Details
.get_from_url(url, image_type, options = {}) ⇒ String
Captures ascreenshot of the webpage under the given url.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/Screenshot.rb', line 40 def self.get_from_url(url, image_type, = {}) UrlUtils.validate(url) validate_image_type(image_type) () temp_file = FileUtils.create_temp_file(image_type) begin Puppeteer.visit(url, PUPPETEER_SCRIPT_PATH, temp_file.path, image_type, ) binary_image_content = FileUtils.read_binary(temp_file.path) ensure FileUtils.delete(temp_file) end return binary_image_content end |
.get_from_url_as_jpeg(url, options = {}) ⇒ String
DEPRECATED: Please use `get_from_url(url, :jpeg)` instead. Captures a full JPEG screenshot of the webpage under the given url.
16 17 18 19 |
# File 'lib/Screenshot.rb', line 16 def self.get_from_url_as_jpeg(url, = {}) warn "[DEPRECATION] `get_from_url_as_jpeg` is deprecated. Use `get_from_url(url, :jpeg)` instead." get_from_url(url, :jpeg, ) end |
.get_from_url_as_png(url, options = {}) ⇒ String
DEPRECATED: Please use `get_from_url(url, :png)` instead. Captures a full PNG screenshot of the webpage under the given url.
28 29 30 31 |
# File 'lib/Screenshot.rb', line 28 def self.get_from_url_as_png(url, = {}) warn "[DEPRECATION] `get_from_url_as_png` is deprecated. Use `get_from_url(url, :png)` instead." get_from_url(url, :png, ) end |