Class Net::SFTP::Response
In: lib/net/sftp/response.rb
Parent: Object

Encapsulates a response from the remote server, to a specific client request. Response objects are passed as parameters to callbacks when you are performing asynchronous operations; when you call Net::SFTP::Request#wait, you can get the corresponding response object via Net::SFTP::Request#response.

  sftp.open("/path/to/file") do |response|
    p response.ok?
    p response[:handle]
  end

  sftp.loop

Methods

[]   eof?   ok?   to_s   to_str  

Included Modules

Net::SFTP::Constants::StatusCodes

Constants

MAP = constants.inject({}) do |memo, name| next memo unless name =~ /^FX_(.*)/

Attributes

code  [R]  The numeric code, one of the FX_* constants
data  [R]  A hash of request-specific data, such as a file handle or attribute information
message  [R]  The textual message for this response (possibly blank)
request  [R]  The request object that this object is in response to

Public Instance methods

Retrieve the data item with the given key. The key is converted to a symbol before being used to lookup the value.

[Source]

    # File lib/net/sftp/response.rb, line 41
41:     def [](key)
42:       data[key.to_sym]
43:     end

Returns true if the status code is FX_EOF; false otherwise.

[Source]

    # File lib/net/sftp/response.rb, line 63
63:     def eof?
64:       code == FX_EOF
65:     end

Returns true if the status code is FX_OK; false otherwise.

[Source]

    # File lib/net/sftp/response.rb, line 58
58:     def ok?
59:       code == FX_OK
60:     end

Returns a textual description of this response, including the status code and name.

[Source]

    # File lib/net/sftp/response.rb, line 47
47:     def to_s
48:       if message && !message.empty? && message.downcase != MAP[code]
49:         "#{message} (#{MAP[code]}, #{code})"
50:       else
51:         "#{MAP[code]} (#{code})"
52:       end
53:     end
to_str()

Alias for to_s

[Validate]