Skip to content

Commit be49501

Browse files
BurdetteLamarmatzbot
authored andcommitted
[ruby/stringio] [DOC] Doc for StringIO#getbyte
(ruby/stringio#162) ruby/stringio@95a7dd592c
1 parent 9ca9407 commit be49501

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

doc/stringio/getbyte.rdoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Reads and returns the next integer byte (not character) from the stream:
2+
3+
s = 'foo'
4+
s.bytes # => [102, 111, 111]
5+
strio = StringIO.new(s)
6+
strio.getbyte # => 102
7+
strio.getbyte # => 111
8+
strio.getbyte # => 111
9+
10+
Returns +nil+ if at end-of-stream:
11+
12+
strio.eof? # => true
13+
strio.getbyte # => nil
14+
15+
Returns a byte, not a character:
16+
17+
s = 'тест'
18+
s.bytes # => [209, 130, 208, 181, 209, 129, 209, 130]
19+
strio = StringIO.new(s)
20+
strio.getbyte # => 209
21+
strio.getbyte # => 130
22+
23+
s = 'こんにちは'
24+
s.bytes # => [227, 129, 147, 227, 130, 147, 227, 129, 171, 227, 129, 161, 227, 129, 175]
25+
strio = StringIO.new(s)
26+
strio.getbyte # => 227
27+
strio.getbyte # => 129
28+
29+
Related: StringIO.getc.

ext/stringio/stringio.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,10 +990,10 @@ strio_getc(VALUE self)
990990

991991
/*
992992
* call-seq:
993-
* getbyte -> byte or nil
993+
* getbyte -> integer or nil
994+
*
995+
* :include: stringio/getbyte.rdoc
994996
*
995-
* Reads and returns the next 8-bit byte from the stream;
996-
* see {Byte IO}[rdoc-ref:IO@Byte+IO].
997997
*/
998998
static VALUE
999999
strio_getbyte(VALUE self)

0 commit comments

Comments
 (0)