Module: Kleya

Defined in:
lib/kleya.rb,
lib/kleya/errors.rb,
lib/kleya/preset.rb,
lib/kleya/browser.rb,
lib/kleya/artifact.rb,
lib/kleya/viewport.rb

Defined Under Namespace

Modules: Preset Classes: Artifact, Browser, Error, TimeoutError, Viewport

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.capture(url, **options) ⇒ String

Returns binary image data.

Examples:

Taking a X-optimized screenshot

Kleya.capture('https://example.com', viewport: :x)

Parameters:

  • url (String)

    the URL to screenshot

  • options (Hash)

    screenshot options

Options Hash (**options):

  • :viewport (Symbol) — default: :desktop

    the viewport to use

  • :format (Symbol) — default: :jpeg

    image format (:jpeg, :png)

  • :quality (Integer) — default: 90

    JPEG quality (1-100)

  • :encoding (Symbol) — default: :binary

    output encoding

Returns:

  • (String)

    binary image data



23
24
25
26
27
28
# File 'lib/kleya.rb', line 23

def self.capture(url, **options)
  browser = Browser.new(**options)
  browser.capture(url, **options)
ensure
  browser.quit
end