Class: Net::FTP::BufferedSocket

Inherits:
BufferedIO show all
Defined in:
lib/net/ftp.rb

Instance Attribute Summary

Attributes inherited from BufferedIO

#continue_timeout, #debug_output, #io, #read_timeout

Instance Method Summary collapse

Methods inherited from BufferedIO

#close, #closed?, #eof?, #initialize, #inspect, #read_all, #readuntil, #write, #writeline

Constructor Details

This class inherits a constructor from Net::BufferedIO

Instance Method Details

#getsObject


1306
1307
1308
1309
# File 'lib/net/ftp.rb', line 1306

def gets
  line = readuntil("\n", true)
  return line.empty? ? nil : line
end

#read(len = nil) ⇒ Object


1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
# File 'lib/net/ftp.rb', line 1292

def read(len = nil)
  if len
    s = super(len, String.new, true)
    return s.empty? ? nil : s
  else
    result = ""
    while s = super(DEFAULT_BLOCKSIZE, String.new, true)
      break if s.empty?
      result << s
    end
    return result
  end
end

#readlineObject


1311
1312
1313
1314
1315
1316
1317
# File 'lib/net/ftp.rb', line 1311

def readline
  line = gets
  if line.nil?
    raise EOFError, "end of file reached"
  end
  return line
end