lib/polyphony/extensions/io.rb in polyphony-0.99.4 vs lib/polyphony/extensions/io.rb in polyphony-0.99.5
- old
+ new
@@ -106,11 +106,11 @@
# @param dest [IO, Polyphony::Pipe] destination to splice to
# @return [Integer] total bytes spliced
def double_splice(src, dest)
Polyphony.backend_double_splice(src, dest)
end
-
+
# Tees data from the source to the desination.
#
# @param src [IO, Polyphony::Pipe] source to tee from
# @param dest [IO, Polyphony::Pipe] destination to tee to
# @param maxlen [Integer] maximum bytes to tee
@@ -230,11 +230,11 @@
# @!visibility private
def <<(str)
Polyphony.backend_write(self, str)
self
end
-
+
# @!visibility private
alias_method :orig_gets, :gets
# @!visibility private
def gets(sep = $/, _limit = nil, _chomp: nil)
@@ -348,28 +348,20 @@
# @!visibility private
def read_nonblock(maxlen, buf = nil, _options = nil)
buf ? readpartial(maxlen, buf) : readpartial(maxlen)
end
- # call-seq:
- # io.read_loop { |data| ... }
- # io.read_loop(maxlen) { |data| ... }
- #
# Reads up to `maxlen` bytes at a time in an infinite loop. Read data
# will be passed to the given block.
#
# @param maxlen [Integer] maximum bytes to receive
- # @yield [String] handler block
+ # @yield [String] read data
# @return [void]
def read_loop(maxlen = 8192, &block)
Polyphony.backend_read_loop(self, maxlen, &block)
end
- # call-seq:
- # io.feed_loop(receiver, method)
- # io.feed_loop(receiver, method) { |result| ... }
- #
# Receives data from the io in an infinite loop, passing the data to the given
# receiver using the given method. If a block is given, the result of the
# method call to the receiver is passed to the block.
#
# This method can be used to feed data into parser objects. The following
@@ -382,10 +374,9 @@
# io.feed_loop(unpacker, :feed_each) { |msg| handle_msg(msg) }
# end
#
# @param receiver [any] receiver object
# @param method [Symbol] method to call
- # @yield [any] block to handle result of method call to receiver
# @return [void]
def feed_loop(receiver, method = :call, &block)
Polyphony.backend_feed_loop(self, receiver, method, &block)
end