Class: Net::SFTP::Request

### Home Classes Methods

### In Files

- lib/net/sftp/request.rb

### Parent

Object

### Methods

- #[]
- #[]=
- #pending?
- #wait

### Included Modules

- Net::SFTP::Constants::PacketTypes

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Net
- Net::SFTP
- Net::SFTP::Constants
- Net::SFTP::Constants::ACE
- Net::SFTP::Constants::ACE::Flag
- Net::SFTP::Constants::ACE::Mask
- Net::SFTP::Constants::ACE::Type
- Net::SFTP::Constants::LockTypes
- Net::SFTP::Constants::OpenFlags
- Net::SFTP::Constants::OpenFlags::FV1
- Net::SFTP::Constants::OpenFlags::FV5
- Net::SFTP::Constants::OpenFlags::FV6
- Net::SFTP::Constants::PacketTypes
- Net::SFTP::Constants::RenameFlags
- Net::SFTP::Constants::StatusCodes
- Net::SFTP::Exception
- Net::SFTP::Operations
- Net::SFTP::Operations::Dir
- Net::SFTP::Operations::Download
- Net::SFTP::Operations::File
- Net::SFTP::Operations::FileFactory
- Net::SFTP::Operations::Upload
- Net::SFTP::Packet
- Net::SFTP::Protocol
- Net::SFTP::Protocol::Base
- Net::SFTP::Protocol::V01
- Net::SFTP::Protocol::V01::Attributes
- Net::SFTP::Protocol::V01::Base
- Net::SFTP::Protocol::V01::Name
- Net::SFTP::Protocol::V02
- Net::SFTP::Protocol::V02::Base
- Net::SFTP::Protocol::V03
- Net::SFTP::Protocol::V03::Base
- Net::SFTP::Protocol::V04
- Net::SFTP::Protocol::V04::Attributes
- Net::SFTP::Protocol::V04::Base
- Net::SFTP::Protocol::V04::Name
- Net::SFTP::Protocol::V05
- Net::SFTP::Protocol::V05::Base
- Net::SFTP::Protocol::V06
- Net::SFTP::Protocol::V06::Attributes
- Net::SFTP::Protocol::V06::Base
- Net::SFTP::Request
- Net::SFTP::Response
- Net::SFTP::Session
- Net::SFTP::StatusException
- Net::SFTP::Version
- Net::SSH
- Net::SSH::Connection
- Net::SSH::Connection::Session

No matching classes.

# Net::SFTP::Request

Encapsulates a single active SFTP request. This is instantiated automatically by the Net::SFTP::Session class when an operation is executed.

    request = sftp.open("/path/to/file")
    puts request.pending? #-> true
    request.wait
    puts request.pending? #-> false
    result = request.response

### Attributes

callback[R]

The callback (if any) associated with this request. When the response is recieved for this request, the callback will be invoked.

id[R]

The SFTP packet identifier for this request

properties[R]

The hash of properties associated with this request. Properties allow programmers to associate arbitrary data with a request, making state machines richer.

response[R]

The response that was received for this request (see Net::SFTP::Response)

session[R]

The Net::SFTP session object that is servicing this request

type[R]

The type of this request (e.g., :open, :symlink, etc.)

### Public Instance Methods

[](key) click to toggle source

Returns the value of property with the given `key`. If `key` is not a symbol, it will be converted to a symbol before lookup.

    # File lib/net/sftp/request.rb, line 50
    def [](key)
      properties[key.to_sym]
    end

[]=(key, value) click to toggle source

Sets the value of the property with name `key` to `value`. If `key` is not a symbol, it will be converted to a symbol before lookup.

    # File lib/net/sftp/request.rb, line 56
    def []=(key, value)
      properties[key.to_sym] = value
    end

pending?() click to toggle source

Returns `true` if the request is still waiting for a response from the server, and `false` otherwise. The SSH event loop must be run in order for a request to be processed; see wait.

    # File lib/net/sftp/request.rb, line 63
    def pending?
      session.pending_requests.key?(id)
    end

wait() click to toggle source

Waits (blocks) until the server responds to this packet. If prior SFTP packets were also pending, they will be processed as well (since SFTP packets are processed in the order in which they are received by the server). Returns the request object itself.

    # File lib/net/sftp/request.rb, line 71
    def wait
      session.loop { pending? }
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.