Ruby StringIO Functions

EditRocket provides the following information on StringIO functions in the Ruby source code builder.

binmode - Returns strio itself. Just for compatibility to IO.

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

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

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

closed? - Returns true if strio is completely closed, false otherwise.

closed_read? - Returns true if strio is not readable, false otherwise.

closed_write? - Returns true if strio is not writable, false otherwise.

each(sep_string=$/) - See IO#each.

each_byte - See IO#each_byte.

each_line(sep_string=$/) - See IO#each.

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

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

fcntl - Raises NotImplementedError.

fileno - Returns nil. Just for compatibility to IO.

flush - Returns strio itself. Just for compatibility to IO.

fsync - Returns 0. Just for compatibility to IO.

getc - See IO#getc.

gets(sep_string=$/) - See IO#gets.

isatty - Returns false. Just for compatibility to IO.

length - Returns the size of the buffer string.

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

lineno - 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.

new" StringIO.new(string=\"\"[, mode]) - Creates new StringIO instance from with string and mode.

open" StringIO.open(string=\"\"[, 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.

path - Returns nil. Just for compatibility to IO.

pid - Returns nil. Just for compatibility to IO.

pos= - Seeks to the given position (in bytes) in strio.

pos - Returns the current offset (in bytes) of strio.

print() - See IO#print.

printf(format_string [, obj, ...] ) - See IO#printf.

putc(obj) - See IO#putc.

puts(obj, ...) - See IO#puts.

read([length [, buffer]]) - See IO#read.

readchar - See IO#readchar.

readline(sep_string=$/) - See IO#readline.

readlines(sep_string=$/) - See IO#readlines.

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

rewind() -

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

size - Returns the size of the buffer string.

string= - Changes underlying String object, the subject of IO.

string - Returns underlying String object, the subject of IO.

sync= - Returns the argument unchanged. Just for compatibility to IO.

sync - Returns true always.

sysread(integer[, outbuf]) - "Similar to #read, but raises EOFError at end of string instead of returning nil, as well as IO#sysread does."

syswrite(string) - 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.

tell - Returns the current offset (in bytes) of strio.

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

tty? - Returns false. Just for compatibility to IO.

ungetc(integer) - 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.

write(string) - 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.