summaryrefslogtreecommitdiff
path: root/lib/net/ssh/buffer.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2007-08-17 03:52:30 +0000
committerJamis Buck <jamis@37signals.com>2007-08-17 03:52:30 +0000
commit5338ecc6eb3023e72d78a510199c152527e07116 (patch)
treebb8ce5338c9a4d1446e19af14aefc8b436a52fb8 /lib/net/ssh/buffer.rb
parenta27b7c5d1f6616019cda4fb1d579fa8e7780971b (diff)
downloadnet-ssh-5338ecc6eb3023e72d78a510199c152527e07116.tar.gz
Starting to document everything
git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@190 1d2a57f2-1ded-0310-ad52-83097a15a5de
Diffstat (limited to 'lib/net/ssh/buffer.rb')
-rw-r--r--lib/net/ssh/buffer.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/net/ssh/buffer.rb b/lib/net/ssh/buffer.rb
index b5dcb39..423a5d7 100644
--- a/lib/net/ssh/buffer.rb
+++ b/lib/net/ssh/buffer.rb
@@ -2,6 +2,16 @@ require 'net/ssh/transport/openssl'
module Net; module SSH
class Buffer
+ # This is a convenience method for creating and populating a new buffer
+ # from a single command. The arguments must be even in length, with the
+ # first of each pair of arguments being a symbol naming the type of the
+ # data that follows. If the type is :raw, the value is written directly
+ # to the hash.
+ #
+ # Example:
+ #
+ # b = Buffer.from(:byte, 1, :string, "hello", :raw, "\1\2\3\4")
+ # #-> "\1\0\0\0\5hello\1\2\3\4"
def self.from(*args)
raise ArgumentError, "odd number of arguments given" unless args.length % 2 == 0
@@ -202,6 +212,8 @@ module Net; module SSH
return key
end
+ # Reads the next string from the buffer, and returns a new Buffer
+ # object that wraps it.
def read_buffer
Buffer.new(read_string)
end