Class: Proclib::OutputHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/proclib/output_handler.rb

Overview

Emits events for the given io pipe with relevant tagging info

Defined Under Namespace

Classes: LineBuffer

Constant Summary collapse

READ_SIZE =
1024
Message =
Class.new(Struct.new(:process_tag, :pipe_name, :line))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, command, channel:) ⇒ OutputHandler



50
51
52
# File 'lib/proclib/output_handler.rb', line 50

def initialize(type, command, channel:)
  @type, @command, @channel = type, command, channel
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



49
50
51
# File 'lib/proclib/output_handler.rb', line 49

def channel
  @channel
end

#commandObject (readonly)

Returns the value of attribute command.



49
50
51
# File 'lib/proclib/output_handler.rb', line 49

def command
  @command
end

#typeObject (readonly)

Returns the value of attribute type.



49
50
51
# File 'lib/proclib/output_handler.rb', line 49

def type
  @type
end

Instance Method Details

#killObject



62
63
64
# File 'lib/proclib/output_handler.rb', line 62

def kill
  @thread.exit
end

#startObject



54
55
56
# File 'lib/proclib/output_handler.rb', line 54

def start
  @thread = Thread.new { monitor }
end

#waitObject



58
59
60
# File 'lib/proclib/output_handler.rb', line 58

def wait
  @thread.join
end