lib/polyphony/extensions/io.rb in polyphony-0.44.0 vs lib/polyphony/extensions/io.rb in polyphony-0.45.0

- old
+ new

@@ -97,22 +97,22 @@ # end alias_method :orig_read, :read def read(len = nil) @read_buffer ||= +'' - result = Thread.current.agent.read(self, @read_buffer, len, true) + result = Thread.current.backend.read(self, @read_buffer, len, true) return nil unless result already_read = @read_buffer @read_buffer = +'' already_read end alias_method :orig_readpartial, :read def readpartial(len, str = nil) @read_buffer ||= +'' - result = Thread.current.agent.read(self, @read_buffer, len, false) + result = Thread.current.backend.read(self, @read_buffer, len, false) raise EOFError unless result if str str << @read_buffer else @@ -122,16 +122,16 @@ str end alias_method :orig_write, :write def write(str, *args) - Thread.current.agent.write(self, str, *args) + Thread.current.backend.write(self, str, *args) end alias_method :orig_write_chevron, :<< def <<(str) - Thread.current.agent.write(self, str) + Thread.current.backend.write(self, str) self end alias_method :orig_gets, :gets def gets(sep = $/, _limit = nil, _chomp: nil) @@ -168,17 +168,16 @@ if args.empty? write "\n" return end - strs = args.inject([]) do |m, a| + strs = args.each_with_object([]) do |a, m| a = a.to_s m << a m << "\n" unless a =~ /\n$/ - m end - write *strs + write(*strs) nil end # def readbyte # end @@ -201,10 +200,10 @@ def read_nonblock(maxlen, buf = nil, _options = nil) buf ? readpartial(maxlen, buf) : readpartial(maxlen) end def read_loop(&block) - Thread.current.agent.read_loop(self, &block) + Thread.current.backend.read_loop(self, &block) end # alias_method :orig_read, :read # def read(length = nil, outbuf = nil) # if length