Class: Glottis::Handlers::ConsoleInputHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/glottis/handlers/console_input_handler.rb

Overview

Holds a reference to the outgoing message queue and posts console input.

Constant Summary collapse

USER_PROMPT =
'> '

Instance Method Summary collapse

Constructor Details

#initialize(outgoing) ⇒ ConsoleInputHandler

Returns a new instance of ConsoleInputHandler.



12
13
14
15
16
# File 'lib/glottis/handlers/console_input_handler.rb', line 12

def initialize(outgoing)
  @outgoing = outgoing
  @running = false
  @thread = nil
end

Instance Method Details

#cleanupObject



28
29
30
31
# File 'lib/glottis/handlers/console_input_handler.rb', line 28

def cleanup
  @running = false
  @thread&.kill if @thread&.alive?
end

#joinObject



24
25
26
# File 'lib/glottis/handlers/console_input_handler.rb', line 24

def join
  @thread&.join
end

#startObject



18
19
20
21
22
# File 'lib/glottis/handlers/console_input_handler.rb', line 18

def start
  @running = true
  @thread = Thread.new { run_loop }
  self
end