Class: Puppeteer::ElementHandle::BoxModel
- Inherits:
-
Object
- Object
- Puppeteer::ElementHandle::BoxModel
- Defined in:
- lib/puppeteer/element_handle/box_model.rb
Constant Summary collapse
- QUAD_ATTRIBUTE_NAMES =
%i(content padding border margin)
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(result_model, offset:) ⇒ BoxModel
constructor
A new instance of BoxModel.
Constructor Details
#initialize(result_model, offset:) ⇒ BoxModel
Returns a new instance of BoxModel.
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
#height ⇒ Object (readonly)
Returns the value of attribute height.
18 19 20 |
# File 'lib/puppeteer/element_handle/box_model.rb', line 18 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
18 19 20 |
# File 'lib/puppeteer/element_handle/box_model.rb', line 18 def width @width end |