Class: Net::FTP::BufferedSocket

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

Direct Known Subclasses

BufferedSSLSocket

Instance Attribute Summary

Attributes inherited from BufferedIO

#continue_timeout, #debug_output, #io, #read_timeout, #write_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



1507
1508
1509
1510
# File 'lib/net/ftp.rb', line 1507

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

#read(len = nil) ⇒ Object



1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
# File 'lib/net/ftp.rb', line 1493

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

#readlineObject



1512
1513
1514
1515
1516
1517
1518
# File 'lib/net/ftp.rb', line 1512

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