mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
[ruby/stringio] [DOC] Doc for StringIO#getbyte
(https://github.com/ruby/stringio/pull/162) https://github.com/ruby/stringio/commit/95a7dd592c
This commit is contained in:
parent
9ca9407573
commit
be495013a7
29
doc/stringio/getbyte.rdoc
Normal file
29
doc/stringio/getbyte.rdoc
Normal file
@ -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.
|
||||
@ -990,10 +990,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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user