Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions ext/stringio/stringio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
* strio.string # => ""
* strio.closed_read? # => false
* strio.closed_write? # => false
* strio.close
*
* If +string+ is frozen, the default +mode+ is <tt>'r'</tt>:
*
* strio = StringIO.new # => #<StringIO>
* strio = StringIO.new('foo'.freeze)
* strio.string # => "foo"
* strio.closed_read? # => false
* strio.closed_write? # => true
* strio.close
*
* The instance should be closed when no longer needed.
* Argument +mode+ must be a valid
* {Access Mode}[https://docs.ruby-lang.org/en/master/File.html#class-File-label-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)
Expand Down