Class StringIO
In: ext/stringio/stringio.c
Parent: Data

Pseudo I/O on String object.

Methods

<<   binmode   close   close_read   close_write   closed?   closed_read?   closed_write?   each   each_byte   each_line   eof   eof?   fcntl   fileno   flush   fsync   getc   gets   isatty   length   lineno   lineno=   new   open   path   pid   pos   pos=   print   printf   putc   puts   read   readchar   readline   readlines   reopen   rewind   seek   size   string   string=   sync   sync=   sysread   syswrite   tell   truncate   tty?   ungetc   write  

Included Modules

Enumerable

Public Class methods

Creates new StringIO instance from with string and mode.

Equivalent to StringIO.new except that when it is called with a block, it yields with the new instance and closes it, and returns the result which returned from the block.

Public Instance methods

strio << obj → strio

See IO#<<.

Returns strio itself. Just for compatibility to IO.

Closes strio. The strio is unavailable for any further data operations; an IOError is raised if such an attempt is made.

Closes the read end of a StringIO. Will raise an IOError if the strio is not readable.

Closes the write end of a StringIO. Will raise an IOError if the strio is not writeable.

Returns true if strio is completely closed, false otherwise.

Returns true if strio is not readable, false otherwise.

Returns true if strio is not writable, false otherwise.

Returns true if strio is at end of file. The stringio must be opened for reading or an IOError will be raised.

Returns true if strio is at end of file. The stringio must be opened for reading or an IOError will be raised.

Returns nil. Just for compatibility to IO.

Returns strio itself. Just for compatibility to IO.

Returns 0. Just for compatibility to IO.

Returns false. Just for compatibility to IO.

Returns the size of the buffer string.

Returns the current line number in strio. The stringio must be opened for reading. lineno counts the number of times gets is called, rather than the number of newlines encountered. The two values will differ if gets is called with a separator other than newline. See also the $. variable.

Manually sets the current line number to the given value. $. is updated only on the next read.

Returns nil. Just for compatibility to IO.

Returns nil. Just for compatibility to IO.

Returns the current offset (in bytes) of strio.

Seeks to the given position (in bytes) in strio.

strio.print() → nil
strio.print(obj, ...) → nil

See IO#print.

strio.printf(format_string [, obj, ...] ) → nil

See IO#printf.

strio.puts(obj, ...) → nil

See IO#puts.

Reinitializes strio with the given other_StrIO or string and mode (see StringIO#new).

Positions strio to the beginning of input, resetting lineno to zero.

Seeks to a given offset amount in the stream according to the value of whence (see IO#seek).

Returns the size of the buffer string.

Returns underlying String object, the subject of IO.

Changes underlying String object, the subject of IO.

Returns true always.

Returns the argument unchanged. Just for compatibility to IO.

Similar to read, but raises EOFError at end of string instead of returning nil, as well as IO#sysread does.

Appends the given string to the underlying buffer string of strio. The stream must be opened for writing. If the argument is not a string, it will be converted to a string using to_s. Returns the number of bytes written. See IO#write.

Returns the current offset (in bytes) of strio.

Truncates the buffer string to at most integer bytes. The strio must be opened for writing.

Returns false. Just for compatibility to IO.

Pushes back one character (passed as a parameter) onto strio such that a subsequent buffered read will return it. Pushing back behind the beginning of the buffer string is not possible. Nothing will be done if such an attempt is made. In other case, there is no limitation for multiple pushbacks.

Appends the given string to the underlying buffer string of strio. The stream must be opened for writing. If the argument is not a string, it will be converted to a string using to_s. Returns the number of bytes written. See IO#write.

[Validate]

ruby-doc.org is a service of James Britt and Neurogami, a Ruby application development company in Phoenix, AZ.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.