Class: Puppeteer::ElementHandle::Point

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

Overview

A class to represent (x, y)-coordinates supporting + and / operators.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:) ⇒ Point

Returns a new instance of Point.



5
6
7
8
# File 'lib/puppeteer/element_handle/point.rb', line 5

def initialize(x:, y:)
  @x = x
  @y = y
end

Instance Attribute Details

#xObject (readonly)

Returns the value of attribute x.



24
25
26
# File 'lib/puppeteer/element_handle/point.rb', line 24

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



24
25
26
# File 'lib/puppeteer/element_handle/point.rb', line 24

def y
  @y
end

Instance Method Details

#+(other) ⇒ Object



10
11
12
13
14
15
# File 'lib/puppeteer/element_handle/point.rb', line 10

def +(other)
  Point.new(
    x: @x + other.x,
    y: @y + other.y,
  )
end

#/(num) ⇒ Object



17
18
19
20
21
22
# File 'lib/puppeteer/element_handle/point.rb', line 17

def /(num)
  Point.new(
    x: @x / num,
    y: @y / num,
  )
end