Class: GitGameShow::Console
- Inherits:
-
Object
- Object
- GitGameShow::Console
- Defined in:
- lib/git_game_show/ui/console.rb
Overview
Handles console input and command processing
Instance Method Summary collapse
-
#initialize(server_handler, renderer) ⇒ Console
constructor
A new instance of Console.
- #setup_command_handler ⇒ Object
Constructor Details
#initialize(server_handler, renderer) ⇒ Console
Returns a new instance of Console.
4 5 6 7 |
# File 'lib/git_game_show/ui/console.rb', line 4 def initialize(server_handler, renderer) @server_handler = server_handler @renderer = renderer end |
Instance Method Details
#setup_command_handler ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/git_game_show/ui/console.rb', line 9 def setup_command_handler # Log initial instructions @renderer.("Available commands: help, start, exit", :cyan) @renderer.("Type a command and press Enter", :cyan) @renderer.("Server is running. Waiting for players to join...", :green) # Handle commands in a separate thread Thread.new do loop do @renderer.draw_command_prompt command = gets&.chomp&.downcase next unless command # Process commands handle_command(command) # Small delay to process any display changes sleep 0.1 end end end |