diff options
| author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2025-10-23 10:24:02 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-10-23 15:24:42 +0000 |
| commit | 6dc879f9d6ca85cd46b54a79a43162c483b36ecc (patch) | |
| tree | a150a22eba7fe606f49800649652cdaa93a4b1b7 /ext/stringio/stringio.c | |
| parent | add78e76cedbe9ce430a0219dd80cbee734080b3 (diff) | |
[ruby/stringio] [DOC] Tweaks for StringIO.new
(https://github.com/ruby/stringio/pull/144)
https://github.com/ruby/stringio/commit/d33ac815c1
Diffstat (limited to 'ext/stringio/stringio.c')
| -rw-r--r-- | ext/stringio/stringio.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index d37dee59ff..18a9ef1523 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -225,17 +225,32 @@ strio_s_allocate(VALUE klass) * call-seq: * StringIO.new(string = '', mode = 'r+') -> new_stringio * - * Note that +mode+ defaults to <tt>'r'</tt> if +string+ is frozen. - * * Returns a new \StringIO instance formed from +string+ and +mode+; - * see {Access Modes}[rdoc-ref:File@Access+Modes]: + * the instance should be closed when no longer needed: * - * strio = StringIO.new # => #<StringIO> + * strio = StringIO.new + * strio.string # => "" + * strio.closed_read? # => false + * strio.closed_write? # => false * strio.close * - * The instance should be closed when no longer needed. + * If +string+ is frozen, the default +mode+ is <tt>'r'</tt>: + * + * strio = StringIO.new('foo'.freeze) + * strio.string # => "foo" + * strio.closed_read? # => false + * strio.closed_write? # => true + * strio.close + * + * Argument +mode+ must be a valid + * {Access Mode}[rdoc-ref:File@Access+Modes], + * which may be a string or an integer constant: + * + * StringIO.new('foo', 'w+') + * StringIO.new('foo', File::RDONLY) * - * Related: StringIO.open (accepts block; closes automatically). + * Related: StringIO.open + * (passes the \StringIO object to the block; closes the object automatically on block exit). */ static VALUE strio_initialize(int argc, VALUE *argv, VALUE self) @@ -712,7 +727,7 @@ strio_set_lineno(VALUE self, VALUE lineno) * binmode -> self * * Sets the data mode in +self+ to binary mode; - * see {Data Mode}[https://docs.ruby-lang.org/en/master/File.html#class-File-label-Data+Mode]. + * see {Data Mode}[rdoc-ref:File@Data+Mode]. * */ static VALUE |
