@@ -937,9 +937,41 @@ strio_get_sync(VALUE self)
937937 * each_byte {|byte| ... } -> self
938938 *
939939 * With a block given, calls the block with each remaining byte in the stream;
940- * see {Byte IO}[rdoc-ref:IO@Byte+IO].
940+ * positions the stream at end-of-file;
941+ * returns +self+:
942+ *
943+ * bytes = []
944+ * strio = StringIO.new('hello') # Five 1-byte characters.
945+ * strio.each_byte {|byte| bytes.push(byte) }
946+ * strio.eof? # => true
947+ * bytes # => [104, 101, 108, 108, 111]
948+ * bytes = []
949+ * strio = StringIO.new('тест') # Four 2-byte characters.
950+ * strio.each_byte {|byte| bytes.push(byte) }
951+ * bytes # => [209, 130, 208, 181, 209, 129, 209, 130]
952+ * bytes = []
953+ * strio = StringIO.new('こんにちは') # Five 3-byte characters.
954+ * strio.each_byte {|byte| bytes.push(byte) }
955+ * bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
956+ *
957+ * The position in the stream matters:
958+ *
959+ * bytes = []
960+ * strio = StringIO.new('こんにちは')
961+ * strio.getc # => "こ"
962+ * strio.pos # => 3 # 3-byte character was read.
963+ * strio.each_byte {|byte| bytes.push(byte) }
964+ * bytes # => [227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
941965 *
942- * With no block given, returns an enumerator.
966+ * If at end-of-file, does not call the block:
967+ *
968+ * strio.eof? # => true
969+ * strio.each_byte {|byte| fail 'Boo!' }
970+ * strio.eof? # => true
971+ *
972+ * With no block given, returns a new {Enumerator}[rdoc-ref:Enumerator].
973+ *
974+ * Related: StringIO#each_char, StringIO#each_codepoint, StringIO#each_line.
943975 */
944976static VALUE
945977strio_each_byte (VALUE self )
@@ -1696,7 +1728,7 @@ strio_readline(int argc, VALUE *argv, VALUE self)
16961728 * "Fifth line"
16971729 * ```
16981730 *
1699- * With no block given, returns a new {Enumerator}[rdoc-ref:Enumerator].
1731+ * With no block given, returns a new {Enumerator}[rdoc-ref:Enumerator].
17001732 *
17011733 * Related: StringIO.each_byte, StringIO.each_char, StringIO.each_codepoint.
17021734 */
0 commit comments