Class: Thaum::InputReader
- Inherits:
-
Object
- Object
- Thaum::InputReader
- Defined in:
- lib/thaum/input_reader.rb
Overview
Reads raw bytes from an input stream in a background thread and pushes KeyEvents onto a queue.
Constant Summary collapse
- ESCAPE_TIMEOUT =
seconds to wait after a bare e before treating it as Escape
0.05
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(input:, queue:, parser: EscapeParser.new) ⇒ InputReader
constructor
A new instance of InputReader.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(input:, queue:, parser: EscapeParser.new) ⇒ InputReader
Returns a new instance of InputReader.
8 9 10 11 12 13 |
# File 'lib/thaum/input_reader.rb', line 8 def initialize(input:, queue:, parser: EscapeParser.new) @input = input @queue = queue @parser = parser @thread = nil end |
Instance Method Details
#alive? ⇒ Boolean
24 25 26 |
# File 'lib/thaum/input_reader.rb', line 24 def alive? @thread&.alive? || false end |
#start ⇒ Object
15 16 17 |
# File 'lib/thaum/input_reader.rb', line 15 def start @thread = Thread.new { run } end |
#stop ⇒ Object
19 20 21 22 |
# File 'lib/thaum/input_reader.rb', line 19 def stop @thread&.join(1) @thread = nil end |