Class: Glottis::Handlers::ConsoleInputHandler

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

Overview

This class holds a reference to the outgoing message queue, and posts messages to it from the console as they are entered.

Constant Summary collapse

USER_PROMPT =
'> '.freeze

Instance Method Summary collapse

Constructor Details

#initialize(outgoing) ⇒ ConsoleInputHandler

Returns a new instance of ConsoleInputHandler.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/glottis/handlers/console_input_handler.rb', line 11

def initialize(outgoing)
  @outgoing = outgoing
  super do
    loop do
      user_input = Readline.readline(USER_PROMPT)
      Readline::HISTORY.push(user_input)

      # if user_input.nil?
      #   raise Glottis::Exceptions::UserExitedException.new
      # end

      @outgoing.push(user_input)
    end
  end
end

Instance Method Details

#cleanupObject



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

def cleanup
  # do nothing
end