Sha256: 8bf5cab3134ef3cf630412e70286e17b93b64419e2a128478480bb85451e8a63

Contents?: true

Size: 578 Bytes

Versions: 2

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

module Fusuma
  module Plugin
    module Buffers
      # Buffer events having KeypressRecord
      class KeypressBuffer < Buffer
        DEFAULT_SOURCE = 'keypress_parser'

        # @param event [Event]
        def buffer(event)
          return if event&.tag != source

          @events.push(event)
          @events.clear if released?
        end

        def empty?
          @events.empty?
        end

        private

        def released?
          true if @events.last.record.status =~ /released/
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fusuma-plugin-keypress-0.1.1 lib/fusuma/plugin/buffers/keypress_buffer.rb
fusuma-plugin-keypress-0.1.0 lib/fusuma/plugin/buffers/keypress_buffer.rb