diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2021-06-02 21:31:20 +0200 |
---|---|---|
committer | Matthias Hecker <36882671+mattzque@users.noreply.github.com> | 2021-06-05 18:06:45 +0200 |
commit | 3c9454d8a1f649f62a4f45461337434a791b1109 (patch) | |
tree | 37d36304be87c1b0d8a1bccbab832136b2ec337a | |
parent | ab23670d711ce0ab3e609421df96d837b6b93350 (diff) |
fix: write override behavior
IO.write() takes an arbitrary number of argumens, that are converted to string
and joined on write. We should behave the same way.
Moreover, the returned value is the number of bytes, and this is bytesize
in modern Ruby.
-rw-r--r-- | lib/rbot/ircbot.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index f9f1758a..564403f5 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -444,17 +444,19 @@ class Bot end end - def $stdout.write(str=nil) + def $stdout.write(*args) + str = args.map { |s| s.to_s }.join("") log str, 2 - return str.to_s.size + return str.bytesize end - def $stderr.write(str=nil) + def $stderr.write(*args) + str = args.map { |s| s.to_s }.join("") if str.to_s.match(/:\d+: warning:/) warning str, 2 else error str, 2 end - return str.to_s.size + return str.bytesize end LoggerManager.instance.log_session_start |