Class: Puppeteer::Viewport

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/viewport.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width:, height:, device_scale_factor: 1.0, is_mobile: false, has_touch: false, is_landscape: false) ⇒ Viewport

Returns a new instance of Viewport.

Parameters:

  • width (int)
  • height (int)
  • device_scale_factor (double) (defaults to: 1.0)
  • is_mobile (boolean) (defaults to: false)
  • has_touch (boolean) (defaults to: false)
  • is_landscape (boolean) (defaults to: false)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/puppeteer/viewport.rb', line 8

def initialize(
      width:,
      height:,
      device_scale_factor: 1.0,
      is_mobile: false,
      has_touch: false,
      is_landscape: false)
  @width = width
  @height = height
  @device_scale_factor = device_scale_factor
  @is_mobile = is_mobile
  @has_touch = has_touch
  @is_landscape = is_landscape
end

Instance Attribute Details

#device_scale_factorObject (readonly)

Returns the value of attribute device_scale_factor.



23
24
25
# File 'lib/puppeteer/viewport.rb', line 23

def device_scale_factor
  @device_scale_factor
end

#heightObject (readonly)

Returns the value of attribute height.



23
24
25
# File 'lib/puppeteer/viewport.rb', line 23

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



23
24
25
# File 'lib/puppeteer/viewport.rb', line 23

def width
  @width
end

Instance Method Details

#has_touch?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/puppeteer/viewport.rb', line 29

def has_touch?
  @has_touch
end

#landscape?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/puppeteer/viewport.rb', line 33

def landscape?
  @is_landscape
end

#mobile?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/puppeteer/viewport.rb', line 25

def mobile?
  @is_mobile
end