module HydroponicBean::Commands::Producer

Public Instance Methods

put(stream, pri, delay, ttr, bytes) click to toggle source
# File lib/hydroponic_bean/commands/producer.rb, line 9
def put(stream, pri, delay, ttr, bytes)
  # Mark this connection as a producer
  producer!

  bytes = bytes.to_i
  data = stream.read(bytes)

  if data.length < bytes
    output(Protocol::BAD_FORMAT)
    return false
  end

  if stream.read(2) != "\r\n"
    output(Protocol::EXPECTED_CRLF)
    return false
  end

  job = create_job(pri, delay, ttr, data)
  output("INSERTED #{job.id}\r\n")
end
use(stream, tube) click to toggle source
# File lib/hydroponic_bean/commands/producer.rb, line 4
def use(stream, tube)
  @current_tube_name = tube
  output("USING #{current_tube_name}\r\n")
end