Class: IO

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

Instance Method Summary collapse

Instance Method Details

#readpartial_rescued(size) ⇒ Object



53
54
55
56
57
# File 'lib/core.rb', line 53

def readpartial_rescued(size)
  readpartial(size)
rescue EOFError
  nil
end

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



45
46
47
48
49
50
51
# File 'lib/core.rb', line 45

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