diff options
| author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2025-11-03 18:58:37 -0600 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-11-04 00:59:03 +0000 |
| commit | be495013a798891945669f940301bd9914d1519d (patch) | |
| tree | 0233f702f188f15168a58c99d6d31a254306df79 /doc | |
| parent | 9ca940757315e53d1eaddc83071b1b4581f8f578 (diff) | |
[ruby/stringio] [DOC] Doc for StringIO#getbyte
(https://github.com/ruby/stringio/pull/162)
https://github.com/ruby/stringio/commit/95a7dd592c
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/stringio/getbyte.rdoc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/stringio/getbyte.rdoc b/doc/stringio/getbyte.rdoc new file mode 100644 index 0000000000..48c334b525 --- /dev/null +++ b/doc/stringio/getbyte.rdoc @@ -0,0 +1,29 @@ +Reads and returns the next integer byte (not character) 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. |
