lib/fusuma/plugin/detectors/keypress_detector.rb in fusuma-plugin-keypress-0.4.0.pre vs lib/fusuma/plugin/detectors/keypress_detector.rb in fusuma-plugin-keypress-0.4.0.pre2

- old
+ new

@@ -3,22 +3,26 @@ module Fusuma module Plugin module Detectors # Detect KeypressEvent from KeypressBuffer class KeypressDetector < Detector + SOURCES = ['keypress'].freeze BUFFER_TYPE = 'keypress' + # Always watch buffers and detect them. + def watch? + true + end + # @param buffers [Array<Event>] # @return [Event] if event is detected # @return [NilClass] if event is NOT detected def detect(buffers) buffer = buffers.find { |b| b.type == BUFFER_TYPE } return if buffer.empty? - records = buffer.events.select do |e| - e.record.status == 'pressed' - end.map(&:record) + records = buffer.events.select { |e| e.record.status == 'pressed' }.map(&:record) index_record = Events::Records::IndexRecord.new( index: create_index(records: records), position: :surfix )