Class | Net::SFTP::Operations::File |
In: |
lib/net/sftp/operations/file.rb
|
Parent: | Object |
A wrapper around an SFTP file handle, that exposes an IO-like interface for interacting with the remote file. All operations are synchronous (blocking), making this a very convenient way to deal with remote files.
A wrapper is usually created via the Net::SFTP::Session#file factory:
file = sftp.file.open("/path/to/remote") puts file.gets file.close
handle | [R] | The SFTP file handle object that this object wraps |
pos | [R] | The current position within the remote file |
sftp | [R] | A reference to the Net::SFTP::Session instance that drives this wrapper |
Creates a new wrapper that encapsulates the given handle (such as would be returned by Net::SFTP::Session#open!). The sftp parameter must be the same Net::SFTP::Session instance that opened the file.
Closes the underlying file and sets the handle to nil. Subsequent operations on this object will fail.
Returns true if the end of the file has been encountered by a previous read. Setting the current file position via pos= will reset this flag (useful if the file‘s contents have changed since the EOF was encountered).
Repositions the file pointer to the given offset (relative to the start of the file). This will also reset the EOF flag.
Writes each argument to the stream. If +$+ is set, it will be written after all arguments have been written.
Writes each argument to the stream, appending a newline to any item that does not already end in a newline. Array arguments are flattened.
Performs an fstat operation on the handle and returns the attribute object (Net::SFTP::Protocol::V01::Attributes, Net::SFTP::Protool::V04::Attributes, or Net::SFTP::Protocol::V06::Attributes, depending on the SFTP protocol version in use).