Class: Rkremap::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(evdev, time, type, code, value) ⇒ Event

Returns a new instance of Event.

Parameters:

  • evdev (Rkremap::Evdev)
  • time (Time)
  • type (Integer)
  • code (Integer)
  • value (Integer)


15
16
17
18
19
20
21
22
23
# File 'lib/rkremap/event.rb', line 15

def initialize(evdev, time, type, code, value)
  @device = evdev
  @time = time
  @ev_type = type
  @code = code
  @value = value
  @app = nil
  @skipped = false
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



3
4
5
# File 'lib/rkremap/event.rb', line 3

def app
  @app
end

#codeObject

Returns the value of attribute code.



7
8
9
# File 'lib/rkremap/event.rb', line 7

def code
  @code
end

#deviceObject (readonly)

Returns the value of attribute device.



4
5
6
# File 'lib/rkremap/event.rb', line 4

def device
  @device
end

#ev_typeObject (readonly)

Returns the value of attribute ev_type.



6
7
8
# File 'lib/rkremap/event.rb', line 6

def ev_type
  @ev_type
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/rkremap/event.rb', line 5

def time
  @time
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/rkremap/event.rb', line 8

def value
  @value
end

Instance Method Details

#inspectObject



25
26
27
28
29
30
31
# File 'lib/rkremap/event.rb', line 25

def inspect
  if ev_type == EV_KEY
    "#<Rkremap::Event: #{code}(#{CODE_KEY[code]}) #{value} #{device.inspect}>"
  else
    "#<Rkremap::Event: type: #{ev_type}>"
  end
end

#match?(device:, code:, type:, app:) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
# File 'lib/rkremap/event.rb', line 37

def match?(device:, code:, type:, app:)
  (device.nil? || self.device.match?(device)) &&
    (code.nil? || Array(code).include?(self.code)) &&
    (type.nil? || Array(type).include?(self.type)) &&
    (app.nil? || @app.nil? || @app.match?(app))
end

#skipObject



44
45
46
# File 'lib/rkremap/event.rb', line 44

def skip
  @skipped = true
end

#skipped?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/rkremap/event.rb', line 48

def skipped?
  @skipped
end

#typeObject



33
34
35
# File 'lib/rkremap/event.rb', line 33

def type
  value == 1 ? :press : value == 0 ? :release : :repeat
end