From 1ebe1c8b1f11d1c2975c4370a4fd3c566132c9d7 Mon Sep 17 00:00:00 2001 From: ksss Date: Mon, 12 Jun 2017 09:32:56 +0900 Subject: Support outbuf argument for IO#read --- mrblib/io.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mrblib/io.rb b/mrblib/io.rb index 694fdb0c9..4262504f2 100644 --- a/mrblib/io.rb +++ b/mrblib/io.rb @@ -181,7 +181,7 @@ class IO nil end - def read(length = nil) + def read(length = nil, outbuf = "") unless length.nil? unless length.is_a? Fixnum raise TypeError.new "can't convert #{length.class} into Integer" @@ -217,7 +217,12 @@ class IO end end - array && array.join + if array.nil? + outbuf.replace("") + nil + else + outbuf.replace(array.join) + end end def readline(arg = $/, limit = nil) -- cgit v1.2.3