Skip to content

Commit 659aca7

Browse files
[DOC] Enhanced RDoc for StringIO (#36)
Treats: - #each_codepoint - #gets - #readline (shows up in doc for module IO::generic_readable, not class StringIO) - #each_line
1 parent 6400af8 commit 659aca7

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

ext/stringio/stringio.c

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,10 +1153,12 @@ strio_each_char(VALUE self)
11531153

11541154
/*
11551155
* call-seq:
1156-
* strio.each_codepoint {|c| block } -> strio
1157-
* strio.each_codepoint -> anEnumerator
1156+
* each_codepoint {|codepoint| ... } -> self
11581157
*
1159-
* See IO#each_codepoint.
1158+
* With a block given, calls the block with each remaining codepoint in the stream;
1159+
* see {Codepoint IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Codepoint+IO].
1160+
*
1161+
* With no block given, returns an enumerator.
11601162
*/
11611163
static VALUE
11621164
strio_each_codepoint(VALUE self)
@@ -1366,11 +1368,13 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
13661368

13671369
/*
13681370
* call-seq:
1369-
* strio.gets(sep=$/, chomp: false) -> string or nil
1370-
* strio.gets(limit, chomp: false) -> string or nil
1371-
* strio.gets(sep, limit, chomp: false) -> string or nil
1371+
* gets(sep = $/, chomp: false) -> string or nil
1372+
* gets(limit, chomp: false) -> string or nil
1373+
* gets(sep, limit, chomp: false) -> string or nil
13721374
*
1373-
* See IO#gets.
1375+
* Reads and returns a line from the stream;
1376+
* assigns the return value to <tt>$_</tt>;
1377+
* see {Line IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Line+IO].
13741378
*/
13751379
static VALUE
13761380
strio_gets(int argc, VALUE *argv, VALUE self)
@@ -1390,11 +1394,12 @@ strio_gets(int argc, VALUE *argv, VALUE self)
13901394

13911395
/*
13921396
* call-seq:
1393-
* strio.readline(sep=$/, chomp: false) -> string
1394-
* strio.readline(limit, chomp: false) -> string or nil
1395-
* strio.readline(sep, limit, chomp: false) -> string or nil
1397+
* readline(sep = $/, chomp: false) -> string
1398+
* readline(limit, chomp: false) -> string
1399+
* readline(sep, limit, chomp: false) -> string
13961400
*
1397-
* See IO#readline.
1401+
* Reads a line as with IO#gets, but raises EOFError if already at end-of-file;
1402+
* see {Line IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Line+IO].
13981403
*/
13991404
static VALUE
14001405
strio_readline(int argc, VALUE *argv, VALUE self)
@@ -1406,17 +1411,16 @@ strio_readline(int argc, VALUE *argv, VALUE self)
14061411

14071412
/*
14081413
* call-seq:
1409-
* strio.each(sep=$/, chomp: false) {|line| block } -> strio
1410-
* strio.each(limit, chomp: false) {|line| block } -> strio
1411-
* strio.each(sep, limit, chomp: false) {|line| block } -> strio
1412-
* strio.each(...) -> anEnumerator
1414+
* each_line(sep = $/, chomp: false) {|line| ... } -> self
1415+
* each_line(limit, chomp: false) {|line| ... } -> self
1416+
* each_line(sep, limit, chomp: false) {|line| ... } -> self
14131417
*
1414-
* strio.each_line(sep=$/, chomp: false) {|line| block } -> strio
1415-
* strio.each_line(limit, chomp: false) {|line| block } -> strio
1416-
* strio.each_line(sep, limit, chomp: false) {|line| block } -> strio
1417-
* strio.each_line(...) -> anEnumerator
1418+
* Calls the block with each remaining line read from the stream;
1419+
* does nothing if already at end-of-file;
1420+
* returns +self+.
1421+
* See {Line IO}[https://docs.ruby-lang.org/en/master/io_streams_rdoc.html#label-Line+IO].
14181422
*
1419-
* See IO#each.
1423+
* StringIO#each is an alias for StringIO#each_line.
14201424
*/
14211425
static VALUE
14221426
strio_each(int argc, VALUE *argv, VALUE self)

0 commit comments

Comments
 (0)