Class: Puppeteer::ElementHandle::BoxModel

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

Constant Summary collapse

QUAD_ATTRIBUTE_NAMES =
%i(content padding border margin)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result_model) ⇒ BoxModel

Returns a new instance of BoxModel.

Parameters:

  • result (Hash)


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/puppeteer/element_handle/box_model.rb', line 5

def initialize(result_model)
  QUAD_ATTRIBUTE_NAMES.each do |attr_name|
    quad = result_model[attr_name.to_s]
    instance_variable_set(
      :"@#{attr_name}",
      quad.each_slice(2).map { |x, y| Point.new(x: x, y: y) },
    )
  end
  @width = result_model['width']
  @height = result_model['height']
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



17
18
19
# File 'lib/puppeteer/element_handle/box_model.rb', line 17

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



17
18
19
# File 'lib/puppeteer/element_handle/box_model.rb', line 17

def width
  @width
end