class Net::SFTP::Protocol::Base

  1. lib/net/sftp/protocol/base.rb
Parent: Protocol

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.

Methods

Public Class

  1. new

Public Instance

  1. parse
  2. session

Included modules

  1. Net::SSH::Loggable
  2. Net::SFTP::Constants
  3. Net::SFTP::Constants::PacketTypes

Attributes

session [R]

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

Public Class methods

new (session)

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

[show source]
# 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)

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).

[show source]
# 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