File: packet.rb

package info (click to toggle)
ruby-net-sftp 1%3A4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 684 kB
  • sloc: ruby: 5,136; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 638 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'net/ssh/buffer'

module Net; module SFTP

  # A specialization of the Net::SSH::Buffer class, which simply auto-reads
  # the type byte from the front of every packet it represents.
  class Packet < Net::SSH::Buffer
    # The (intger) type of this packet. See Net::SFTP::Constants for all
    # possible packet types.
    attr_reader :type

    # Create a new Packet object that wraps the given +data+ (which should be
    # a String). The first byte of the data will be consumed automatically and
    # interpreted as the #type of this packet.
    def initialize(data)
      super
      @type = read_byte
    end
  end

end; end