Class: Fusuma::Plugin::Detectors::AppmatcherDetector

Inherits:
Detector
  • Object
show all
Defined in:
lib/fusuma/plugin/detectors/appmatcher_detector.rb

Overview

Detect KeypressEvent from KeypressBuffer

Constant Summary collapse

SOURCES =
['appmatcher']
BUFFER_TYPE =
'appmatcher'
DEFAULT_NAME =
'global'

Instance Method Summary collapse

Instance Method Details

#detect(buffers) ⇒ Event, NilClass

Parameters:

  • buffers (Array<Event>)

Returns:

  • (Event)

    if event is detected

  • (NilClass)

    if event is NOT detected



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fusuma/plugin/detectors/appmatcher_detector.rb', line 20

def detect(buffers)
  buffer = buffers.find { |b| b.type == BUFFER_TYPE }

  return if buffer.empty?

  record = buffer.events.last.record

  context_record = Events::Records::ContextRecord.new(
    name: 'application',
    value: record.name
  )

  create_event(record: context_record)
end

#watch?Boolean

Always watch buffers and detect them.

Returns:

  • (Boolean)


13
14
15
# File 'lib/fusuma/plugin/detectors/appmatcher_detector.rb', line 13

def watch?
  true
end