Class: IO

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#while_reading(data = nil, &b) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/core_ext.rb', line 2

def while_reading(data = nil, &b)
  while buf = readpartial_rescued(16384)
    data << buf  if data
    yield buf  if block_given?
  end
  data
end