From 3221157ea22f5ff9bb816b8e024e034e9352283a Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Mon, 3 Nov 2025 20:17:36 +0000 Subject: [PATCH 1/2] [DOC] Doc for StringIO#getbyte --- doc/stringio/getbyte.rdoc | 29 +++++++++++++++++++++++++++++ ext/stringio/stringio.c | 6 +++--- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 doc/stringio/getbyte.rdoc diff --git a/doc/stringio/getbyte.rdoc b/doc/stringio/getbyte.rdoc new file mode 100644 index 0000000..da39a8b --- /dev/null +++ b/doc/stringio/getbyte.rdoc @@ -0,0 +1,29 @@ +Reads and returns the next byte (not characte) from the stream: + + s = 'foo' + s.bytes # => [102, 111, 111] + strio = StringIO.new(s) + strio.getbyte # => 102 + strio.getbyte # => 111 + strio.getbyte # => 111 + +Returns +nil+ if at end-of-stream: + + strio.eof? # => true + strio.getbyte # => nil + +Returns a byte, not a character: + + s = 'тест' + s.bytes # => [209, 130, 208, 181, 209, 129, 209, 130] + strio = StringIO.new(s) + strio.getbyte # => 209 + strio.getbyte # => 130 + + s = 'こんにちは' + s.bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175] + strio = StringIO.new(s) + strio.getbyte # => 227 + strio.getbyte # => 129 + +Related: StringIO.getc. diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 874a3a1..3c192a1 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -982,10 +982,10 @@ strio_getc(VALUE self) /* * call-seq: - * getbyte -> byte or nil + * getbyte -> integer or nil + * + * :include: stringio/getbyte.rdoc * - * Reads and returns the next 8-bit byte from the stream; - * see {Byte IO}[rdoc-ref:IO@Byte+IO]. */ static VALUE strio_getbyte(VALUE self) From c342aabcd53cde82a32a044c249057923a5f9291 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Mon, 3 Nov 2025 20:21:26 +0000 Subject: [PATCH 2/2] [DOC] Doc for StringIO#getbyte --- doc/stringio/getbyte.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/stringio/getbyte.rdoc b/doc/stringio/getbyte.rdoc index da39a8b..48c334b 100644 --- a/doc/stringio/getbyte.rdoc +++ b/doc/stringio/getbyte.rdoc @@ -1,4 +1,4 @@ -Reads and returns the next byte (not characte) from the stream: +Reads and returns the next integer byte (not character) from the stream: s = 'foo' s.bytes # => [102, 111, 111]