Class: Puppeteer::Viewport
- Inherits:
- 
      Object
      
        - Object
- Puppeteer::Viewport
 
- Defined in:
- lib/puppeteer/viewport.rb
Instance Attribute Summary collapse
- 
  
    
      #device_scale_factor  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute device_scale_factor. 
- 
  
    
      #height  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute height. 
- 
  
    
      #width  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute width. 
Instance Method Summary collapse
- #has_touch? ⇒ Boolean
- 
  
    
      #initialize(width:, height:, device_scale_factor: 1.0, is_mobile: false, has_touch: false, is_landscape: false)  ⇒ Viewport 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Viewport. 
- #landscape? ⇒ Boolean
- #merge(width: nil, height: nil, device_scale_factor: nil, is_mobile: nil, has_touch: nil, is_landscape: nil) ⇒ Object
- #mobile? ⇒ Boolean
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.
| 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_factor ⇒ Object (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 | 
#height ⇒ Object (readonly)
Returns the value of attribute height.
| 23 24 25 | # File 'lib/puppeteer/viewport.rb', line 23 def height @height end | 
#width ⇒ Object (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
| 29 30 31 | # File 'lib/puppeteer/viewport.rb', line 29 def has_touch? @has_touch end | 
#landscape? ⇒ Boolean
| 33 34 35 | # File 'lib/puppeteer/viewport.rb', line 33 def landscape? @is_landscape end | 
#merge(width: nil, height: nil, device_scale_factor: nil, is_mobile: nil, has_touch: nil, is_landscape: nil) ⇒ Object
| 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # File 'lib/puppeteer/viewport.rb', line 37 def merge( width: nil, height: nil, device_scale_factor: nil, is_mobile: nil, has_touch: nil, is_landscape: nil) Puppeteer::Viewport.new( width: width || @width, height: height || @height, device_scale_factor: device_scale_factor || @device_scale_factor, is_mobile: is_mobile.nil? ? @is_mobile : is_mobile, has_touch: has_touch.nil? ? @has_touch : has_touch, is_landscape: is_landscape.nil? ? @is_landscape : is_landscape, ) end | 
#mobile? ⇒ Boolean
| 25 26 27 | # File 'lib/puppeteer/viewport.rb', line 25 def mobile? @is_mobile end |