Class: Puppeteer::TouchScreen

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

Overview

rbs_inline: enabled

Instance Method Summary collapse

Constructor Details

#initialize(client, keyboard) ⇒ TouchScreen

Returns a new instance of TouchScreen.

Parameters:



9
10
11
12
13
14
# File 'lib/puppeteer/touch_screen.rb', line 9

def initialize(client, keyboard)
  @client = client
  @keyboard = keyboard
  @touch_id_counter = 0
  @touches = []
end

Instance Method Details

#tap(x, y) ⇒ void

This method returns an undefined value.

Parameters:

  • x (Numeric)
  • y (Numeric)


25
26
27
28
# File 'lib/puppeteer/touch_screen.rb', line 25

def tap(x, y)
  touch = touch_start(x, y)
  touch.end
end

#touch_endvoid

This method returns an undefined value.



66
67
68
69
70
71
# File 'lib/puppeteer/touch_screen.rb', line 66

def touch_end
  touch = @touches.shift
  raise Puppeteer::TouchError.new('Must start a new Touch first') unless touch

  touch.end
end

#touch_move(x, y) ⇒ void

This method returns an undefined value.

Parameters:

  • x (Numeric)
  • y (Numeric)


56
57
58
59
60
61
# File 'lib/puppeteer/touch_screen.rb', line 56

def touch_move(x, y)
  touch = @touches.first
  raise Puppeteer::TouchError.new('Must start a new Touch first') unless touch

  touch.move(x, y)
end

#touch_start(x, y) ⇒ Puppeteer::TouchHandle

Parameters:

  • x (Numeric)
  • y (Numeric)

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/puppeteer/touch_screen.rb', line 35

def touch_start(x, y)
  @touch_id_counter += 1
  touch_point = {
    x: x.round,
    y: y.round,
    radiusX: 0.5,
    radiusY: 0.5,
    force: 0.5,
    id: @touch_id_counter,
  }
  touch = Puppeteer::TouchHandle.new(self, touch_point)
  touch.start
  @touches << touch
  touch
end

#update_client(client) ⇒ void

This method returns an undefined value.

Parameters:



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

def update_client(client)
  @client = client
end