mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #85 from ksss/read
Support outbuf argument for IO#read
This commit is contained in:
+7
-2
@@ -183,7 +183,7 @@ class IO
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(length = nil)
|
def read(length = nil, outbuf = "")
|
||||||
unless length.nil?
|
unless length.nil?
|
||||||
unless length.is_a? Fixnum
|
unless length.is_a? Fixnum
|
||||||
raise TypeError.new "can't convert #{length.class} into Integer"
|
raise TypeError.new "can't convert #{length.class} into Integer"
|
||||||
@@ -215,7 +215,12 @@ class IO
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
array && array.join
|
if array.nil?
|
||||||
|
outbuf.replace("")
|
||||||
|
nil
|
||||||
|
else
|
||||||
|
outbuf.replace(array.join)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def readline(arg = $/, limit = nil)
|
def readline(arg = $/, limit = nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user