Class: Charai::ActionQueue
- Inherits:
-
Object
- Object
- Charai::ActionQueue
- Defined in:
- lib/charai/action_queue.rb
Instance Method Summary collapse
-
#initialize ⇒ ActionQueue
constructor
A new instance of ActionQueue.
- #key_down(value:) ⇒ Object
- #key_up(value:) ⇒ Object
- #pause(duration:) ⇒ Object
-
#pointer_down(button:) ⇒ Object
button: 0 for left, 1 for middle, 2 for right.
- #pointer_move(x:, y:, duration: nil) ⇒ Object
-
#pointer_up(button:) ⇒ Object
button: 0 for left, 1 for middle, 2 for right.
- #scroll(x:, y:, delta_x: 0, delta_y: 0, duration: nil) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ ActionQueue
Returns a new instance of ActionQueue.
3 4 5 |
# File 'lib/charai/action_queue.rb', line 3 def initialize @actions = [] end |
Instance Method Details
#key_down(value:) ⇒ Object
15 16 17 |
# File 'lib/charai/action_queue.rb', line 15 def key_down(value:) @actions << { type: 'keyDown', value: value } end |
#key_up(value:) ⇒ Object
19 20 21 |
# File 'lib/charai/action_queue.rb', line 19 def key_up(value:) @actions << { type: 'keyUp', value: value } end |
#pause(duration:) ⇒ Object
11 12 13 |
# File 'lib/charai/action_queue.rb', line 11 def pause(duration:) @actions << { type: 'pause', duration: duration } end |
#pointer_down(button:) ⇒ Object
button: 0 for left, 1 for middle, 2 for right
24 25 26 |
# File 'lib/charai/action_queue.rb', line 24 def pointer_down(button:) @actions << { type: 'pointerDown', button: } end |
#pointer_move(x:, y:, duration: nil) ⇒ Object
28 29 30 |
# File 'lib/charai/action_queue.rb', line 28 def pointer_move(x:, y:, duration: nil) @actions << { type: 'pointerMove', x: x, y: y, duration: duration }.compact end |
#pointer_up(button:) ⇒ Object
button: 0 for left, 1 for middle, 2 for right
33 34 35 |
# File 'lib/charai/action_queue.rb', line 33 def pointer_up(button:) @actions << { type: 'pointerUp', button: } end |
#scroll(x:, y:, delta_x: 0, delta_y: 0, duration: nil) ⇒ Object
37 38 39 |
# File 'lib/charai/action_queue.rb', line 37 def scroll(x:, y:, delta_x: 0, delta_y: 0, duration: nil) @actions << { type: 'scroll', x: x, y: y, deltaX: delta_x, deltaY: delta_y, duration: duration }.compact end |
#to_a ⇒ Object
7 8 9 |
# File 'lib/charai/action_queue.rb', line 7 def to_a @actions end |