class IO

Extending of standart IO class

Public Instance Methods

gett(time) click to toggle source

Reads the next “packet” from I/O stream. Packets are separated by time delay. @param time [Integer] time delay between packets in seconds. @example

server.print "Foo"
sleep 0.1
server.print "Bar"
sleep 0.1
server.print "Foo"
client.gett(0.1)    #=> "Foo"
client.gett(0.2)    #=> "BarFoo"

@return [String] recieved packet string

# File lib/rumid/io.rb, line 19
def gett(time)
  raw = getc
  loop {
    begin
      timeout(time){raw << getc}
    rescue Timeout::Error
      break
    end
  }
  raw
end