Sha256: 527cf92bf74dd1364f1e6437bc1309296c9efefedf02293f30915f3a6501048e
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Fusuma module Plugin module Detectors # Detect KeypressEvent from KeypressBuffer class KeypressDetector < Detector BUFFER_TYPE = 'keypress' # @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.map(&:record) index = create_index(records: records) index_record = Events::Records::IndexRecord.new( index: index, position: :surfix ) create_event(record: index_record) end # @param records [Array<Events::Records::KeypressRecord>] # @return [Config::Index] def create_index(records:) code = records.map(&:code).join('+') Config::Index.new( [ Config::Index::Key.new('keypress', skippable: true), Config::Index::Key.new(code, skippable: true) ] ) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fusuma-plugin-keypress-0.2.0 | lib/fusuma/plugin/detectors/keypress_detector.rb |
fusuma-plugin-keypress-0.1.1 | lib/fusuma/plugin/detectors/keypress_detector.rb |