Class: IO

Inherits:
Object
  • Object
show all
Includes:
Timeout
Defined in:
lib/rumid/io.rb

Overview

Extending of standart IO class

Instance Method Summary collapse

Instance Method Details

#gett(time) ⇒ String

Reads the next “packet” from I/O stream. Packets are separated by time delay.

Examples:

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"

Parameters:

  • time (Integer)

    time delay between packets in seconds.

Returns:

  • (String)

    recieved packet string


19
20
21
22
23
24
25
26
27
28
29
# 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