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"].freeze
BUFFER_TYPE =
"appmatcher"

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



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

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)


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

def watch?
  true
end