Class: Glottis::Handlers::ConsoleOutputHandler

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

Overview

Holds a reference to incoming message queue and prints messages to stdout.

Instance Method Summary collapse

Constructor Details

#initialize(incoming) ⇒ ConsoleOutputHandler

Returns a new instance of ConsoleOutputHandler.



7
8
9
10
11
# File 'lib/glottis/handlers/console_output_handler.rb', line 7

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

Instance Method Details

#cleanupObject



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

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

#joinObject



19
20
21
# File 'lib/glottis/handlers/console_output_handler.rb', line 19

def join
  @thread&.join
end

#startObject



13
14
15
16
17
# File 'lib/glottis/handlers/console_output_handler.rb', line 13

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