Skip to content

Commit

Permalink
[DOC] Enhanced RDoc for StringIO (#35)
Browse files Browse the repository at this point in the history
Treated:
- #getc
- #getbyte
- #ungetc
- #ungetbyte
- #readchar
- #readbyte
- #each_char
  • Loading branch information
BurdetteLamar authored Oct 19, 2022
1 parent 6fabe7c commit 6400af8
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions ext/stringio/stringio.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,9 +935,10 @@ strio_each_byte(VALUE self)

/*
* call-seq:
* strio.getc -> string or nil
* getc -> character or nil
*
* See IO#getc.
* Reads and returns the next character from the stream;
* see {Character IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Character+IO].
*/
static VALUE
strio_getc(VALUE self)
Expand All @@ -960,9 +961,10 @@ strio_getc(VALUE self)

/*
* call-seq:
* strio.getbyte -> fixnum or nil
* getbyte -> byte or nil
*
* See IO#getbyte.
* Reads and returns the next 8-bit byte from the stream;
* see {Byte IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Byte+IO].
*/
static VALUE
strio_getbyte(VALUE self)
Expand Down Expand Up @@ -998,12 +1000,10 @@ strio_extend(struct StringIO *ptr, long pos, long len)

/*
* call-seq:
* strio.ungetc(string) -> nil
* ungetc(character) -> nil
*
* Pushes back one character (passed as a parameter)
* such that a subsequent buffered read will return it. There is no
* limitation for multiple pushbacks including pushing back behind the
* beginning of the buffer string.
* Pushes back ("unshifts") a character or integer onto the stream;
* see {Character IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Character+IO].
*/
static VALUE
strio_ungetc(VALUE self, VALUE c)
Expand Down Expand Up @@ -1038,9 +1038,10 @@ strio_ungetc(VALUE self, VALUE c)

/*
* call-seq:
* strio.ungetbyte(fixnum) -> nil
* ungetbyte(byte) -> nil
*
* See IO#ungetbyte
* Pushes back ("unshifts") an 8-bit byte onto the stream;
* see {Byte IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Byte+IO].
*/
static VALUE
strio_ungetbyte(VALUE self, VALUE c)
Expand Down Expand Up @@ -1100,9 +1101,10 @@ strio_unget_bytes(struct StringIO *ptr, const char *cp, long cl)

/*
* call-seq:
* strio.readchar -> string
* readchar -> string
*
* See IO#readchar.
* Like +getc+, but raises an exception if already at end-of-stream;
* see {Character IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Character+IO].
*/
static VALUE
strio_readchar(VALUE self)
Expand All @@ -1114,9 +1116,10 @@ strio_readchar(VALUE self)

/*
* call-seq:
* strio.readbyte -> fixnum
* readbyte -> byte
*
* See IO#readbyte.
* Like +getbyte+, but raises an exception if already at end-of-stream;
* see {Byte IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Byte+IO].
*/
static VALUE
strio_readbyte(VALUE self)
Expand All @@ -1128,10 +1131,12 @@ strio_readbyte(VALUE self)

/*
* call-seq:
* strio.each_char {|char| block } -> strio
* strio.each_char -> anEnumerator
* each_char {|c| ... } -> self
*
* See IO#each_char.
* With a block given, calls the block with each remaining character in the stream;
* see {Character IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Character+IO].
*
* With no block given, returns an enumerator.
*/
static VALUE
strio_each_char(VALUE self)
Expand Down

0 comments on commit 6400af8

Please sign in to comment.