module HydroponicBean::Protocol

Constants

BAD_FORMAT
DRAINING
EXPECTED_CRLF
INTERNAL_ERROR
JOB_TOO_BIG
NOT_FOUND
OUT_OF_MEMORY
UNKNOWN_COMMAND

Public Instance Methods

parse(stream) click to toggle source
# File lib/hydroponic_bean/protocol.rb, line 17
def parse(stream)
  while (line = stream.gets("\r\n")) do
    if line.slice!(-2..-1) != "\r\n"
      output(BAD_FORMAT)
      return
    end

    command, *args = line.split
    HydroponicBean.commands[command] += 1
    command.tr!('-', '_')
    if !send(command, *([stream] + args))
      return
    end
  end
end