Class: IO

Inherits:
Object
  • Object
show all
Defined in:
lib/gpstool/extensions/io.rb

Overview

This file is part of the “GPSTool” project, and is distributed under the MIT License. Copyright © 2011 Samuel G. D. Williams. <www.oriontransfer.co.nz> See <LICENSE.txt> for licensing details.

Instance Method Summary collapse

Instance Method Details

#readbytes(length) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gpstool/extensions/io.rb', line 6

def readbytes(length)
	buffer = ""
	
	while buffer.size < length
		begin
			buffer += read(length - buffer.size)
			$stderr.puts "(*readbytes) -> #{buffer.dump}"
		rescue Errno::EAGAIN
			IO.select([self], [], [])
			retry
		end
	end
	
	return buffer
end