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.



22
23
24
25
26
# File 'lib/applitools/core/mouse_trigger.rb', line 22

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.



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

def control
  @control
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#mouse_actionObject (readonly)

Returns the value of attribute mouse_action.



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

def mouse_action
  @mouse_action
end

Instance Method Details

#to_hashObject



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

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

#to_sObject



37
38
39
# File 'lib/applitools/core/mouse_trigger.rb', line 37

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