Class: Puppeteer::TouchHandle
- Inherits:
-
Object
- Object
- Puppeteer::TouchHandle
- Defined in:
- lib/puppeteer/touch_handle.rb
Overview
rbs_inline: enabled
Instance Attribute Summary collapse
-
#touch_point ⇒ Object
readonly
Returns the value of attribute touch_point.
Instance Method Summary collapse
- #end ⇒ Object
-
#initialize(touchscreen, touch_point) ⇒ TouchHandle
constructor
A new instance of TouchHandle.
- #move(x, y) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(touchscreen, touch_point) ⇒ TouchHandle
Returns a new instance of TouchHandle.
7 8 9 10 11 |
# File 'lib/puppeteer/touch_handle.rb', line 7 def initialize(touchscreen, touch_point) @touchscreen = touchscreen @touch_point = touch_point @started = false end |
Instance Attribute Details
#touch_point ⇒ Object (readonly)
Returns the value of attribute touch_point.
13 14 15 |
# File 'lib/puppeteer/touch_handle.rb', line 13 def touch_point @touch_point end |
Instance Method Details
#end ⇒ Object
35 36 37 38 |
# File 'lib/puppeteer/touch_handle.rb', line 35 def end @touchscreen.send(:dispatch_touch_event, 'touchEnd', [@touch_point]) @touchscreen.send(:remove_handle, self) end |
#move(x, y) ⇒ Object
28 29 30 31 32 |
# File 'lib/puppeteer/touch_handle.rb', line 28 def move(x, y) @touch_point[:x] = x.round @touch_point[:y] = y.round @touchscreen.send(:dispatch_touch_event, 'touchMove', [@touch_point]) end |
#start ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/puppeteer/touch_handle.rb', line 16 def start if @started raise Puppeteer::TouchError.new('Touch has already started') end @touchscreen.send(:dispatch_touch_event, 'touchStart', [@touch_point]) @started = true end |