| Class | StringIO |
| In: |
ext/stringio/stringio.c
|
| Parent: | Data |
Pseudo I/O on String object.
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.
Closes strio. The strio is unavailable for any further data operations; an IOError is raised if such an attempt is made.
See IO#each.
See IO#each.
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 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.
Reinitializes strio with the given other_StrIO or string and mode (see StringIO#new).
Seeks to a given offset amount in the stream according to the value of whence (see IO#seek).
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.
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.