diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-23 14:05:07 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-23 14:05:07 +0000 |
commit | 30d23ec9035ae62d11a7ffe632297206b0d74da5 (patch) | |
tree | 67ba57fca1504e79f0f56765985a589a0c28d1b5 | |
parent | 8bbdbf9e75ecdfbc8bfaac4c5c2637332c0aa0bf (diff) | |
download | ruby-30d23ec9035ae62d11a7ffe632297206b0d74da5.tar.gz |
multiple arguments to write
Make write methods of IO-like objects accept multiple arguments,
as well as IO#write.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ext/openssl/lib/openssl/buffering.rb | 3 | ||||
-rw-r--r-- | test/lib/envutil.rb | 2 | ||||
-rw-r--r-- | test/logger/test_logdevice.rb | 2 | ||||
-rw-r--r-- | test/mkmf/base.rb | 6 | ||||
-rw-r--r-- | test/optparse/test_autoconf.rb | 2 | ||||
-rw-r--r-- | test/optparse/test_kwargs.rb | 2 | ||||
-rw-r--r-- | test/optparse/test_optparse.rb | 2 |
7 files changed, 10 insertions, 9 deletions
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb index 8b5dd9da57..f328c0007d 100644 --- a/ext/openssl/lib/openssl/buffering.rb +++ b/ext/openssl/lib/openssl/buffering.rb @@ -339,7 +339,8 @@ module OpenSSL::Buffering # Writes _s_ to the stream. If the argument is not a String it will be # converted using +.to_s+ method. Returns the number of bytes written. - def write(s) + def write(*s) + s = s.size == 1 ? s[0] : s.join("") do_write(s) s.bytesize end diff --git a/test/lib/envutil.rb b/test/lib/envutil.rb index f2b266484d..45b6eb47fb 100644 --- a/test/lib/envutil.rb +++ b/test/lib/envutil.rb @@ -160,7 +160,7 @@ module EnvUtil def verbose_warning class << (stderr = "".dup) - alias write << + alias write concat end stderr, $stderr, verbose, $VERBOSE = $stderr, stderr, $VERBOSE, true yield stderr diff --git a/test/logger/test_logdevice.rb b/test/logger/test_logdevice.rb index 14d7bbce6a..7d5bf9ac81 100644 --- a/test/logger/test_logdevice.rb +++ b/test/logger/test_logdevice.rb @@ -75,7 +75,7 @@ class TestLogDevice < Test::Unit::TestCase # logdev = d(LogExcnRaiser.new) class << (stderr = '') - alias write << + alias write concat end $stderr, stderr = stderr, $stderr begin diff --git a/test/mkmf/base.rb b/test/mkmf/base.rb index 86bdd29286..3ba3e03387 100644 --- a/test/mkmf/base.rb +++ b/test/mkmf/base.rb @@ -49,11 +49,11 @@ module TestMkmf::Base def filter(&block) @filter = block end - def write(s) + def write(*s) if @out - @buffer << s + @buffer.concat(*s) elsif @origin - @origin << s + @origin.write(*s) end end end diff --git a/test/optparse/test_autoconf.rb b/test/optparse/test_autoconf.rb index 4b3616f816..3be4a4c598 100644 --- a/test/optparse/test_autoconf.rb +++ b/test/optparse/test_autoconf.rb @@ -14,7 +14,7 @@ class TestOptionParser::AutoConf < Test::Unit::TestCase end class DummyOutput < String - alias write << + alias write concat end def no_error(*args) $stderr, stderr = DummyOutput.new, $stderr diff --git a/test/optparse/test_kwargs.rb b/test/optparse/test_kwargs.rb index 68fe207a2c..78d7e2ee9c 100644 --- a/test/optparse/test_kwargs.rb +++ b/test/optparse/test_kwargs.rb @@ -14,7 +14,7 @@ class TestOptionParser::KwArg < Test::Unit::TestCase end class DummyOutput < String - alias write << + alias write concat end def assert_no_error(*args) $stderr, stderr = DummyOutput.new, $stderr diff --git a/test/optparse/test_optparse.rb b/test/optparse/test_optparse.rb index a2540db241..e4aeb07aac 100644 --- a/test/optparse/test_optparse.rb +++ b/test/optparse/test_optparse.rb @@ -9,7 +9,7 @@ class TestOptionParser < Test::Unit::TestCase end class DummyOutput < String - alias write << + alias write concat end def assert_no_error(*args) $stderr, stderr = DummyOutput.new, $stderr |