Class: Deskbot::Event::MouseMove

Inherits:
Event
  • Object
show all
Defined in:
lib/deskbot/event.rb

Overview

The mouse moved to a new position. Exposes #x, #y and #coords.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:, recorded_at:) ⇒ MouseMove

rubocop:disable Naming/MethodParameterName



115
116
117
118
119
# File 'lib/deskbot/event.rb', line 115

def initialize(x:, y:, recorded_at:) # rubocop:disable Naming/MethodParameterName
  @x = x
  @y = y
  @recorded_at = recorded_at
end

Instance Attribute Details

#x ⇒ Object (readonly)

Returns the value of attribute x.



113
114
115
# File 'lib/deskbot/event.rb', line 113

def x
  @x
end

#y ⇒ Object (readonly)

Returns the value of attribute y.



113
114
115
# File 'lib/deskbot/event.rb', line 113

def y
  @y
end

Class Method Details

.build(payload) ⇒ Object



121
122
123
124
125
126
127
# File 'lib/deskbot/event.rb', line 121

def self.build(payload)
  new(
    x: payload["x"],
    y: payload["y"],
    recorded_at: recorded_at_from(payload)
  )
end

Instance Method Details

#coords ⇒ Object

Returns the mouse position as [x, y].



130
131
132
# File 'lib/deskbot/event.rb', line 130

def coords
  [x, y]
end