Class: Fusuma::Plugin::Buffers::KeypressBuffer

Inherits:
Buffer
  • Object
show all
Defined in:
lib/fusuma/plugin/buffers/keypress_buffer.rb

Overview

Buffer events having KeypressRecord

Constant Summary collapse

DEFAULT_SOURCE =
"keypress_parser"

Instance Method Summary collapse

Instance Method Details

#buffer(event) ⇒ Object

Parameters:

  • event (Event)


17
18
19
20
21
# File 'lib/fusuma/plugin/buffers/keypress_buffer.rb', line 17

def buffer(event)
  return if event&.tag != source

  @events.push(event)
end

#clear_expiredObject



23
24
25
26
27
28
29
30
# File 'lib/fusuma/plugin/buffers/keypress_buffer.rb', line 23

def clear_expired(*)
  return if @events.empty?

  return unless released?

  released_code = @events.last.record.code
  @events.delete_if { |e| e.record.code == released_code }
end

#config_param_typesObject



10
11
12
13
14
# File 'lib/fusuma/plugin/buffers/keypress_buffer.rb', line 10

def config_param_types
  {
    source: [String]
  }
end

#empty?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/fusuma/plugin/buffers/keypress_buffer.rb', line 32

def empty?
  @events.empty?
end