@@ -75,10 +75,10 @@ module Screenshot
7575 # page.screenshot(path: "google.jpg") # => 30902
7676 #
7777 # @example Save to Base64 in WebP with reduce quality:
78- # page.screenshot(format: ' webp' , quality: 60) # "iVBORw0KGgoAAAANS...
78+ # page.screenshot(format: " webp" , quality: 60) # "iVBORw0KGgoAAAANS...
7979 #
8080 # @example Save to Base64 the whole page not only viewport and reduce quality:
81- # page.screenshot(full: true, format: ' jpeg' , quality: 60) # "iVBORw0KGgoAAAANS...
81+ # page.screenshot(full: true, format: " jpeg" , quality: 60) # "iVBORw0KGgoAAAANS...
8282 #
8383 # @example Save with specific background color:
8484 # page.screenshot(background_color: Ferrum::RGBA.new(0, 0, 0, 0.0))
@@ -216,24 +216,24 @@ def screenshot_options(path = nil, format: nil, scale: 1.0, **options)
216216 screenshot_options
217217 end
218218
219- def format_options ( screenshot_format , path , quality )
220- if !screenshot_format && path # try to infer from path
221- extension = File . extname ( path ) . delete ( "." ) & .downcase
222- screenshot_format = extension if extension && ! extension . empty?
219+ def format_options ( format , path , quality )
220+ if !format && path # try to infer from path
221+ extension = File . extname ( path ) . delete ( "." ) . downcase
222+ format = extension unless extension . empty?
223223 end
224224
225- screenshot_format ||= DEFAULT_SCREENSHOT_FORMAT
226- screenshot_format = screenshot_format . to_s
227- unless SUPPORTED_SCREENSHOT_FORMAT . include? ( screenshot_format )
228- raise "Not supported options `:format` #{ screenshot_format } . #{ SUPPORTED_SCREENSHOT_FORMAT . join ( ' | ' ) } "
225+ format ||= DEFAULT_SCREENSHOT_FORMAT
226+ format = format . to_s
227+ unless SUPPORTED_SCREENSHOT_FORMAT . include? ( format )
228+ raise Ferrum :: InvalidScreenshotFormatError , format
229229 end
230230
231- screenshot_format = "jpeg" if screenshot_format == "jpg"
231+ format = "jpeg" if format == "jpg"
232232
233233 # Chrome supports screenshot qualities for JPEG and WebP
234- quality ||= 75 if screenshot_format != "png"
234+ quality ||= 75 if format != "png"
235235
236- [ screenshot_format , quality ]
236+ [ format , quality ]
237237 end
238238
239239 def area_options ( full , selector , scale , area = nil )
0 commit comments