Class: Puppeteer::ElementHandle::BoxModel

Inherits:
Object
  • Object
show all
Defined in:
lib/puppeteer/element_handle/box_model.rb,
sig/_supplementary.rbs

Constant Summary collapse

QUAD_ATTRIBUTE_NAMES =
%i(content padding border margin)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result_model, offset:) ⇒ BoxModel

Returns a new instance of BoxModel.

Parameters:



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

def initialize(result_model, offset:)
  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) + offset },
    )
  end
  @width = result_model['width']
  @height = result_model['height']
end

Instance Attribute Details

#borderArray[Puppeteer::ElementHandle::Point] (readonly)

Returns the value of attribute border.



82
83
84
# File 'sig/_supplementary.rbs', line 82

def border
  @border
end

#contentArray[Puppeteer::ElementHandle::Point] (readonly)

Returns the value of attribute content.



80
81
82
# File 'sig/_supplementary.rbs', line 80

def content
  @content
end

#heightNumeric (readonly)

Returns the value of attribute height.

Returns:

  • (Numeric)


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

def height
  @height
end

#marginArray[Puppeteer::ElementHandle::Point] (readonly)

Returns the value of attribute margin.



83
84
85
# File 'sig/_supplementary.rbs', line 83

def margin
  @margin
end

#paddingArray[Puppeteer::ElementHandle::Point] (readonly)

Returns the value of attribute padding.



81
82
83
# File 'sig/_supplementary.rbs', line 81

def padding
  @padding
end

#widthNumeric (readonly)

Returns the value of attribute width.

Returns:

  • (Numeric)


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

def width
  @width
end