Class: Net::SFTP::Protocol::Base

### Home Classes Methods

### In Files

- lib/net/sftp/protocol/base.rb

### Parent

Object

### Methods

- ::new
- #parse

### Included Modules

- Net::SSH::Loggable
- Net::SFTP::Constants
- 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::Protocol::Base

The abstract superclass of the specific implementations for each supported SFTP protocol version. It implements general packet parsing logic, and provides a way for subclasses to send requests.

### Attributes

session[R]

The SFTP session object that acts as client to this protocol instance

### Public Class Methods

new(session) click to toggle source

Create a new instance of a protocol driver, servicing the given session.

    # File lib/net/sftp/protocol/base.rb, line 18
    def initialize(session)
      @session = session
      self.logger = session.logger
      @request_id_counter = -1
    end

### Public Instance Methods

parse(packet) click to toggle source

Attept to parse the given packet. If the packet is of an unsupported type, an exception will be raised. Returns the parsed data as a hash (the keys in the hash are packet-type specific).

    # File lib/net/sftp/protocol/base.rb, line 27
    def parse(packet)
      case packet.type
      when FXP_STATUS then parse_status_packet(packet)
      when FXP_HANDLE then parse_handle_packet(packet)
      when FXP_DATA   then parse_data_packet(packet)
      when FXP_NAME   then parse_name_packet(packet)
      when FXP_ATTRS  then parse_attrs_packet(packet)
      else raise NotImplementedError, "unknown packet type: #{packet.type}"
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.