summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/net/ftp.rb14
-rw-r--r--lib/net/http.rb12
-rw-r--r--lib/net/pop.rb6
-rw-r--r--lib/net/protocol.rb10
-rw-r--r--lib/net/smtp.rb6
-rw-r--r--lib/net/telnet.rb14
6 files changed, 32 insertions, 30 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index ab10853bed..7383b003c7 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -276,7 +276,7 @@ module Net
end
def retrlines(cmd, callback = nil)
- if iterator?
+ if block_given?
callback = Proc.new
elsif not callback.is_a?(Proc)
callback = Proc.new {|line| print line, "\n"}
@@ -300,7 +300,7 @@ module Net
end
def storbinary(cmd, file, blocksize, rest_offset = nil, callback = nil)
- if iterator?
+ if block_given?
callback = Proc.new
end
use_callback = callback.is_a?(Proc)
@@ -319,7 +319,7 @@ module Net
end
def storlines(cmd, file, callback = nil)
- if iterator?
+ if block_given?
callback = Proc.new
end
use_callback = callback.is_a?(Proc)
@@ -342,7 +342,7 @@ module Net
def getbinaryfile(remotefile, localfile,
blocksize = DEFAULT_BLOCKSIZE, callback = nil)
- if iterator?
+ if block_given?
callback = Proc.new
end
use_callback = callback.is_a?(Proc)
@@ -365,7 +365,7 @@ module Net
end
def gettextfile(remotefile, localfile, callback = nil)
- if iterator?
+ if block_given?
callback = Proc.new
end
use_callback = callback.is_a?(Proc)
@@ -383,7 +383,7 @@ module Net
def putbinaryfile(localfile, remotefile,
blocksize = DEFAULT_BLOCKSIZE, callback = nil)
- if iterator?
+ if block_given?
callback = Proc.new
end
use_callback = callback.is_a?(Proc)
@@ -404,7 +404,7 @@ module Net
end
def puttextfile(localfile, remotefile, callback = nil)
- if iterator?
+ if block_given?
callback = Proc.new
end
use_callback = callback.is_a?(Proc)
diff --git a/lib/net/http.rb b/lib/net/http.rb
index e5822d6138..65cd5a9937 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -33,7 +33,7 @@ the terms of the Ruby Distribute License.
: start {|http| .... }
creates a new Net::HTTP object and starts HTTP session.
- When this method is called as iterator, gives HTTP object to block
+ When this method is called with a block, gives HTTP object to block
and close HTTP session after block call finished.
: get( path, header = nil, dest = '' )
@@ -46,7 +46,7 @@ the terms of the Ruby Distribute License.
# example
response, body = http.get( '/index.html' )
- If called as iterator, give a part String of entity body.
+ If called with a block, give a part String of entity body.
Note:
If status is not 2xx(success), ProtocolError exception is
@@ -81,7 +81,7 @@ the terms of the Ruby Distribute License.
"header" must be a Hash like { 'Accept' => '*/*', ... }.
This method returns Net::HTTPResponse object and "dest".
- If called as iterator, gives a part String of entity body.
+ If called with a block, gives a part String of entity body.
: get2( path, header = nil ) {|adapter| .... }
send GET request for "path".
@@ -165,7 +165,7 @@ All "key" is case-insensitive.
entity body. A body is written to "dest" using "<<" method.
: body {|str| ... }
- get entity body by using iterator.
+ get entity body by using block.
If this method is called twice, block is not called and
returns first "dest".
@@ -350,11 +350,13 @@ module Net
@socket.reopen
end
- resp = yield( u_header )
+ yield( u_header )
if ublock then
adapter = HTTPReadAdapter.new( @command )
ublock.call adapter
resp = adapter.off
+ else
+ resp = @command.get_response
end
unless keep_alive? u_header, resp then
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 6e12d4064a..61f7b52cad 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -31,7 +31,7 @@ Net::Protocol
: start( account, password ) {|pop| .... }
starts POP3 session.
- When called as iterator, give a POP3 object to block and
+ When called with a block, give a POP3 object to block and
close session after block call is finished.
: each {|popmail| .... }
@@ -80,7 +80,7 @@ Object
end
: all {|str| .... }
- You can use all/pop/mail as the iterator.
+ You can use all/pop/mail with a block.
argument 'str' is a read string (a part of mail).
# usage example
@@ -180,7 +180,7 @@ module Net
end
def all( dest = '' )
- if iterator? then
+ if block_given? then
dest = NetPrivate::ReadAdapter.new( Proc.new )
end
@command.retr( @num, dest )
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index 16d6cac747..3eced45d3a 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -46,7 +46,7 @@ Object
'*args' are specified in subclasses.
- When is called as iterator, gives Protocol object to block and
+ When is called with a block, gives Protocol object to block and
close session when block finished.
: finish
@@ -73,7 +73,7 @@ module Net
def start( address = 'localhost', port = nil, *args )
instance = new( address, port )
- if iterator? then
+ if block_given? then
instance.start( *args ) { yield instance }
else
instance.start( *args )
@@ -167,9 +167,9 @@ module Net
connect
do_start( *args )
@active = true
- yield self if iterator?
+ yield self if block_given?
ensure
- finish if iterator?
+ finish if block_given?
end
end
@@ -561,7 +561,7 @@ module Net
while (str = readuntil( "\r\n" )) != ".\r\n" do
str.chop!
arr.push str
- yield str if iterator?
+ yield str if block_given?
end
@pipe << "read #{arr.size} lines\n" if pipeon
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 53bed4910b..f7af92d635 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -33,7 +33,7 @@ Net::Protocol
opens TCP connection and starts SMTP session.
If protocol had been started, do nothing and return false.
- When this methods is called as iterator, give a SMTP object to block and
+ When this methods is called with a block, give a SMTP object to block and
close session after block call finished.
If account and password are given, is trying to get authentication
@@ -42,7 +42,7 @@ Net::Protocol
: send_mail( mailsrc, from_addr, *to_addrs )
: sendmail( mailsrc, from_addr, *to_addrs )
This method sends 'mailsrc' as mail. SMTP read strings
- from 'mailsrc' by calling 'each' iterator, and convert them
+ from 'mailsrc' by calling 'each' method, and convert them
into "\r\n" terminated string when write.
from_addr must be String.
@@ -62,7 +62,7 @@ Net::Protocol
: ready( from_addr, to_addrs ) {|adapter| .... }
This method stands by the SMTP object for sending mail.
- In the block of this iterator, you can call ONLY 'write' method
+ In the block of this method, you can call ONLY 'write' method
for 'adapter'.
# usage example
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
index 1b8a52bc78..44bb223ddf 100644
--- a/lib/net/telnet.rb
+++ b/lib/net/telnet.rb
@@ -312,7 +312,7 @@ module Net
end
else
message = "Trying " + @options["Host"] + "...\n"
- yield(message) if iterator?
+ yield(message) if block_given?
@log.write(message) if @options.has_key?("Output_log")
@dumplog.log_dump('#', message) if @options.has_key?("Dump_log")
@@ -335,7 +335,7 @@ module Net
@sock.binmode
message = "Connected to " + @options["Host"] + ".\n"
- yield(message) if iterator?
+ yield(message) if block_given?
@log.write(message) if @options.has_key?("Output_log")
@dumplog.log_dump('#', message) if @options.has_key?("Dump_log")
end
@@ -489,11 +489,11 @@ module Net
end
@log.print(buf) if @options.has_key?("Output_log")
line.concat(buf)
- yield buf if iterator?
+ yield buf if block_given?
rescue EOFError # End of file reached
if line == ''
line = nil
- yield nil if iterator?
+ yield nil if block_given?
end
break
end
@@ -554,7 +554,7 @@ module Net
end
self.puts(string)
- if iterator?
+ if block_given?
waitfor({"Prompt" => match, "Timeout" => time_out}){|c| yield c }
else
waitfor({"Prompt" => match, "Timeout" => time_out})
@@ -569,7 +569,7 @@ module Net
username = options
end
- if iterator?
+ if block_given?
line = waitfor(/login[: ]*\z/n){|c| yield c }
if password
line.concat( cmd({"String" => username,
@@ -706,7 +706,7 @@ end
* 1999/04/11 - wakou
* version 0.163
- * STDOUT.write(message) --> yield(message) if iterator?
+ * STDOUT.write(message) --> yield(message) if block_given?
* 1999/03/17 - wakou
* version 0.162