aboutsummaryrefslogtreecommitdiffstats
path: root/lib/openssl/buffering.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2017-10-23 16:47:21 +0900
committerKazuki Yamaguchi <k@rhe.jp>2017-10-23 16:47:21 +0900
commitcfa154fa577d4e4d0f551b1b3ed9502d24963ec0 (patch)
tree1858c2cdf7b51e936abdebf13c5670d10610f2c5 /lib/openssl/buffering.rb
parente72d960db2623b21ee001b5a7b9d9e6ff55bdf94 (diff)
downloadruby-openssl-cfa154fa577d4e4d0f551b1b3ed9502d24963ec0.tar.gz
buffering: let #write accept multiple argumentsky/ssl-write-multi
As of Ruby 2.5, IO#write accepts multiple input strings and writes them at once[1]. Follow that. [1] https://bugs.ruby-lang.org/issues/9323
Diffstat (limited to 'lib/openssl/buffering.rb')
-rw-r--r--lib/openssl/buffering.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/openssl/buffering.rb b/lib/openssl/buffering.rb
index 8b5dd9da..935f61f0 100644
--- a/lib/openssl/buffering.rb
+++ b/lib/openssl/buffering.rb
@@ -339,9 +339,11 @@ 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)
- do_write(s)
- s.bytesize
+ def write(*s)
+ s.inject(0) do |written, str|
+ do_write(str)
+ written + str.bytesize
+ end
end
##