@@ -2046,15 +2046,10 @@ def read_all
2046
2046
#
2047
2047
# If the read buffer is not empty, read_nonblock reads from the
2048
2048
# buffer like readpartial. In this case, read(2) is not called.
2049
- def read_nonblock ( size , buffer = nil , opts = { } )
2049
+ def read_nonblock ( size , buffer = nil , exception : true )
2050
2050
raise ArgumentError , "illegal read size" if size < 0
2051
2051
ensure_open
2052
2052
2053
- if buffer . is_a? ( Hash )
2054
- opts = buffer
2055
- buffer = nil
2056
- end
2057
-
2058
2053
buffer = StringValue buffer if buffer
2059
2054
2060
2055
if @ibuffer . size > 0
@@ -2064,7 +2059,7 @@ def read_nonblock(size, buffer=nil, opts={})
2064
2059
begin
2065
2060
str = read_if_available ( size )
2066
2061
rescue EAGAINWaitReadable => exc
2067
- raise exc unless opts [ : exception] == false
2062
+ raise exc if exception
2068
2063
2069
2064
return :wait_readable
2070
2065
end
@@ -2073,7 +2068,7 @@ def read_nonblock(size, buffer=nil, opts={})
2073
2068
buffer . replace ( str ) if buffer
2074
2069
return str
2075
2070
else
2076
- raise EOFError , "stream closed" unless opts [ : exception] == false
2071
+ raise EOFError , "stream closed" if exception
2077
2072
end
2078
2073
end
2079
2074
@@ -2602,7 +2597,7 @@ def write(data)
2602
2597
data . bytesize
2603
2598
end
2604
2599
2605
- def write_nonblock ( data , opts = { } )
2600
+ def write_nonblock ( data , exception : true )
2606
2601
ensure_open_and_writable
2607
2602
2608
2603
data = String data
@@ -2612,7 +2607,7 @@ def write_nonblock(data, opts={})
2612
2607
2613
2608
raw_write ( data )
2614
2609
rescue EAGAINWaitWritable => exc
2615
- raise exc unless opts [ : exception] == false
2610
+ raise exc if exception
2616
2611
2617
2612
return :wait_writable
2618
2613
end
0 commit comments