summaryrefslogtreecommitdiff
path: root/lib/net/protocol.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-26 08:48:15 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-26 08:48:15 +0000
commitd8d148d81653d7be02ee2d4237b5e75856e02ee3 (patch)
treefb8b3458ccde7a9923c0ab9b33ef77f1bdf0f899 /lib/net/protocol.rb
parent688169fd83b24564b653c03977c168cea50ccd35 (diff)
o protocol.rb: version 1.1.9
o smtp.rb: arguments discription of do_ready was wrongly void git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/protocol.rb')
-rw-r--r--lib/net/protocol.rb136
1 files changed, 27 insertions, 109 deletions
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 1f1df17..3a200d5 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -15,7 +15,7 @@ require 'socket'
module Net
- Version = '1.1.7'
+ Version = '1.1.9'
=begin
@@ -219,27 +219,6 @@ Object
Session = Protocol
-=begin
-
-== Net::Command
-
-=== Super Class
-
-Object
-
-=== Class Methods
-
-: new( socket )
- This method create new Command object. 'socket' must be ProtocolSocket.
- This method is abstract class.
-
-
-=== Methods
-
-: quit
- This method dispatch command which ends the protocol.
-
-=end
class Command
@@ -317,10 +296,26 @@ Object
def initialize( cod, mes )
@code = cod
@msg = mes
+ @data = nil
end
attr_reader :code, :msg
+ def []( key )
+ if @data then
+ @data[key]
+ else
+ nil
+ end
+ end
+
+ def []=( key, val )
+ unless h = @data then
+ @data = h = {}
+ end
+ h[key] = val
+ end
+
def error!( sending )
mes = <<MES
@@ -370,78 +365,6 @@ MES
end
-=begin
-
-== Net::ProtocolSocket
-
-=== Super Class
-
-Object
-
-=== Class Methods
-
-: new( address = 'localhost', port = nil )
- This create new ProtocolSocket object, and connect to server.
-
-
-=== Methods
-
-: close
- This method closes socket.
-
-: address, addr
- a FQDN address of server
-
-: ip_address, ipaddr
- an IP address of server
-
-: port
- connecting port number.
-
-: closed?
- true if ProtocolSokcet have been closed already
-
-
-: read( length )
- This method read 'length' bytes and return the string.
-
-: readuntil( target )
- This method read until find 'target'. Returns read string.
-
-: readline
- read until "\r\n" and returns it without "\r\n".
-
-: read_pendstr
- This method read until "\r\n.\r\n".
- At the same time, delete period at line head and final line ("\r\n.\r\n").
-
-: read_pendlist
-: read_pendlist{|line| .... }
- This method read until "\r\n.\r\n". This method resembles to 'read_pendstr',
- but 'read_pendlist' don't check period at line head, and returns array which
- each element is one line.
-
- When this method was called with block, evaluate it for each reading a line.
-
-
-: write( src )
- This method send 'src'. ProtocolSocket read strings from 'src' by 'each'
- iterator. This method returns written bytes.
-
-: writebin( src )
- This method send 'src'. ProtocolSokcet read string from 'src' by 'each'
- iterator. This method returns written bytes.
-
-: writeline( str )
- This method writes 'str'. There has not to be bare "\r" or "\n" in 'str'.
-
-: write_pendstr( src )
- This method writes 'src' as a mail.
- ProtocolSocket reads strings from 'src' by 'each' iterator.
- This returns written bytes.
-
-=end
-
class WriteAdapter
@@ -639,35 +562,30 @@ Object
public
- def writeline( str )
+ def write( str )
do_write_beg
do_write_do str
- do_write_do CRLF
do_write_fin
end
- def writebin( src )
+ def writeline( str )
do_write_beg
- if iterator? then
- yield WriteAdapter.new( self, :do_write_do )
- else
- src.each do |bin|
- do_write_do bin
- end
- end
+ do_write_do str
+ do_write_do CRLF
do_write_fin
end
- def write( src )
+ def write_bin( src, block = nil )
do_write_beg
- if iterator? then
- yield WriteAdapter.new( self, :write_inner )
+ if block then
+ block.call WriteAdapter.new( self, :do_write_do )
else
- write_inner src
+ src.each do |bin|
+ do_write_do bin
+ end
end
- each_crlf_line2( :i_w )
do_write_fin
end