Class: Rkremap::Event
- Inherits:
-
Object
- Object
- Rkremap::Event
- Defined in:
- lib/rkremap/event.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#code ⇒ Object
Returns the value of attribute code.
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#ev_type ⇒ Object
readonly
Returns the value of attribute ev_type.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(evdev, time, type, code, value) ⇒ Event
constructor
A new instance of Event.
- #inspect ⇒ Object
- #match?(device:, code:, type:, app:) ⇒ Boolean
- #skip ⇒ Object
- #skipped? ⇒ Boolean
- #type ⇒ Object
Constructor Details
#initialize(evdev, time, type, code, value) ⇒ Event
Returns a new instance of Event.
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
#app ⇒ Object
Returns the value of attribute app.
3 4 5 |
# File 'lib/rkremap/event.rb', line 3 def app @app end |
#code ⇒ Object
Returns the value of attribute code.
7 8 9 |
# File 'lib/rkremap/event.rb', line 7 def code @code end |
#device ⇒ Object (readonly)
Returns the value of attribute device.
4 5 6 |
# File 'lib/rkremap/event.rb', line 4 def device @device end |
#ev_type ⇒ Object (readonly)
Returns the value of attribute ev_type.
6 7 8 |
# File 'lib/rkremap/event.rb', line 6 def ev_type @ev_type end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/rkremap/event.rb', line 5 def time @time end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/rkremap/event.rb', line 8 def value @value end |
Instance Method Details
#inspect ⇒ Object
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
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 |
#skip ⇒ Object
44 45 46 |
# File 'lib/rkremap/event.rb', line 44 def skip @skipped = true end |
#skipped? ⇒ Boolean
48 49 50 |
# File 'lib/rkremap/event.rb', line 48 def skipped? @skipped end |
#type ⇒ Object
33 34 35 |
# File 'lib/rkremap/event.rb', line 33 def type value == 1 ? :press : value == 0 ? :release : :repeat end |