Class: Applitools::MouseTrigger

Inherits:
Trigger
  • Object
show all
Defined in:
lib/applitools/core/mouse_trigger.rb

Constant Summary collapse

TRIGGER_TYPE =
:Mouse
MOUSE_ACTION =

A hash contains available mouse actions: :click, :right_click, :double_click, :move, :down, :up

{
  click: 'Click',
  right_click: 'RightClick',
  double_click: 'DoubleClick',
  move: 'Move',
  down: 'Down',
  up: 'Up'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Trigger

#trigger_type

Constructor Details

#initialize(mouse_action, control, location) ⇒ MouseTrigger

Returns a new instance of MouseTrigger.



20
21
22
23
24
# File 'lib/applitools/core/mouse_trigger.rb', line 20

def initialize(mouse_action, control, location)
  @mouse_action = mouse_action
  @control = control
  @location = location
end

Instance Attribute Details

#controlObject (readonly)

Returns the value of attribute control.



18
19
20
# File 'lib/applitools/core/mouse_trigger.rb', line 18

def control
  @control
end

#locationObject (readonly)

Returns the value of attribute location.



18
19
20
# File 'lib/applitools/core/mouse_trigger.rb', line 18

def location
  @location
end

#mouse_actionObject (readonly)

Returns the value of attribute mouse_action.



18
19
20
# File 'lib/applitools/core/mouse_trigger.rb', line 18

def mouse_action
  @mouse_action
end

Instance Method Details

#to_hashObject



26
27
28
29
30
31
32
33
# File 'lib/applitools/core/mouse_trigger.rb', line 26

def to_hash
  {
    triggerType: trigger_type,
    mouseAction: MOUSE_ACTION[mouse_action],
    control: control.to_hash,
    location: location.to_hash
  }
end

#to_sObject



35
36
37
# File 'lib/applitools/core/mouse_trigger.rb', line 35

def to_s
  "#{mouse_action} [#{control}] #{location.x}, #{location.y}"
end