Sha256: 390ea6dca61bf1c7594dfb56b6d29fda3a1478d3ad66be91b7cbbeaa18102ee4

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

module Necro
  class CommandWorker
    attr_accessor :command_label, :pipe_end, :pid, :color
    
    def initialize(command_label, pipe_end, pid, color)
      @command_label = command_label
      @pipe_end = pipe_end
      @pid = pid
      @color = color
    end

    # Copied verbatim from Eventmachine code
    def receive_data data
      (@buf ||= '') << data

      while @buf.slice!(/(.*?)\r?\n/)
        receive_line($1)
      end
    end

    def unbind
      # $stdout.print(".")
    end

    # Print the lines received over the network
    def receive_line(line)
      $stdout.puts "#{@command_label.send(color)} : #{line}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
necro-0.0.2 lib/necro/command_worker.rb