Class: StringIO
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
          ::Data
         | |
| Instance Chain: | |
| Inherits: | Data 
 | 
| Defined in: | ext/stringio/stringio.c | 
Overview
Class Method Summary
- 
    
      .new(string=""[, mode])  
    
    constructor
    Creates new StringIOinstance from with string and mode.
- 
    
      .open(string=""[, mode]) {|strio| ... } 
    
    Equivalent to .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. 
Instance Attribute Summary
- 
    
      #lineno  ⇒ Integer 
    
    rw
    Returns the current line number in strio. 
- 
    
      #lineno=(integer)  ⇒ Integer 
    
    rw
    Manually sets the current line number to the given value. 
- 
    
      #pos  ⇒ Integer 
    
    rw
    Returns the current offset (in bytes) of strio. 
- 
    
      #pos=(integer)  ⇒ Integer 
    
    rw
    Seeks to the given position (in bytes) in strio. 
- 
    
      #string  ⇒ String 
    
    rw
    Returns underlying String object, the subject of ::IO. 
- 
    
      #string=(string)  ⇒ String 
    
    rw
    Changes underlying String object, the subject of ::IO. 
- 
    
      #closed?  ⇒ Boolean 
    
    readonly
    Returns trueif strio is completely closed,falseotherwise.
- 
    
      #closed_read?  ⇒ Boolean 
    
    readonly
    Returns trueif strio is not readable,falseotherwise.
- 
    
      #closed_write?  ⇒ Boolean 
    
    readonly
    Returns trueif strio is not writable,falseotherwise.
- 
    
      #eof  ⇒ Boolean 
      (also: #eof?)
    
    readonly
    Returns true if strio is at end of file. 
- 
    
      #eof?  ⇒ Boolean 
    
    readonly
    Alias for #eof. 
- #tty? ⇒ Boolean readonly
Instance Method Summary
- #binmode ⇒ true
- 
    
      #bytes  
    
    This is a deprecated alias for #each_byte. 
- 
    
      #chars  
    
    This is a deprecated alias for #each_char. 
- 
    
      #close  ⇒ nil 
    
    Closes strio. 
- 
    
      #close_read  ⇒ nil 
    
    Closes the read end of a StringIO.
- 
    
      #close_write  ⇒ nil 
    
    Closes the write end of a StringIO.
- 
    
      #codepoints  
    
    This is a deprecated alias for #each_codepoint. 
- 
    
      #each(sep = $/) {|line| ... } ⇒ strio 
      (also: #each_line)
    
    strio.each_line(sep=$/) {|line| block } -> strio. 
- 
    
      #each_byte {|byte| ... } ⇒ strio 
    
    See IO#each_byte.
- 
    
      #each_char {|char| ... } ⇒ strio 
    
    See IO#each_char.
- 
    
      #each_codepoint {|c| ... } ⇒ strio 
    
    See IO#each_codepoint.
- 
    
      #each(sep = $/) {|line| ... } ⇒ strio 
    
    Alias for #each. 
- 
    
      #external_encoding  ⇒ Encoding 
    
    Returns the Encoding object that represents the encoding of the file. 
- #fcntl
- #fileno
- #flush
- #fsync
- 
    
      #getbyte  ⇒ Fixnum? 
    
    See IO#getbyte.
- 
    
      #getc  ⇒ String? 
    
    See IO#getc.
- 
    
      #gets(sep = $/)  ⇒ String? 
    
    See IO#gets.
- 
    
      #internal_encoding  ⇒ Encoding 
    
    Returns the Encoding of the internal string if conversion is specified. 
- #isatty
- 
    
      #length  ⇒ Integer 
      (also: #size)
    
    Returns the size of the buffer string. 
- 
    
      #lines(*args)  
    
    This is a deprecated alias for #each_line. 
- #pid
- 
    
      #putc(obj)  ⇒ Object 
    
    See IO#putc.
- 
    
      #read([length [, outbuf]])  ⇒ String, ... 
    
    See IO#read.
- 
    
      #readlines(sep = $/)  ⇒ Array 
    
    See IO#readlines.
- 
    
      #reopen(other_StrIO)  ⇒ strio 
    
    Reinitializes strio with the given other_StrIO or string and mode (see StringIO#new).
- 
    
      #rewind  ⇒ 0 
    
    Positions strio to the beginning of input, resetting #lineno to zero. 
- 
    
      #seek(amount, whence = SEEK_SET)  ⇒ 0 
    
    Seeks to a given offset amount in the stream according to the value of whence (see IO#seek).
- 
    
      #set_encoding(ext_enc, [int_enc[, opt]])  ⇒ strio 
    
    Specify the encoding of the StringIOas ext_enc.
- 
    
      #size  ⇒ Integer 
    
    Alias for #length. 
- 
    
      #sync  ⇒ true 
    
    Returns truealways.
- #sync=
- #tell
- 
    
      #truncate(integer)  ⇒ 0 
    
    Truncates the buffer string to at most integer bytes. 
- 
    
      #ungetbyte(fixnum)  ⇒ nil 
    
    See IO#ungetbyte
- 
    
      #ungetc(string)  ⇒ nil 
    
    Pushes back one character (passed as a parameter) onto strio such that a subsequent buffered read will return it. 
- 
    
      #write(string)  ⇒ Integer 
    
    Appends the given string to the underlying buffer string of strio. 
::IO::generic_readable - Included
| #read_nonblock | Similar to #read, but raises  | 
| #readbyte | See  | 
| #readchar | See  | 
| #readline | See  | 
| #readpartial | Alias for IO::generic_readable#sysread. | 
| #sysread | Similar to #read, but raises  | 
::IO::generic_writable - Included
Constructor Details
.new(string=""[, mode])
Creates new StringIO instance from with string and mode.
Class Method Details
.open(string=""[, mode]) {|strio| ... }
Equivalent to .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.
Instance Attribute Details
    #closed?  ⇒ Boolean  (readonly)  
Returns true if strio is completely closed, false otherwise.
    #closed_read?  ⇒ Boolean  (readonly)  
Returns true if strio is not readable, false otherwise.
    #closed_write?  ⇒ Boolean  (readonly)  
Returns true if strio is not writable, false otherwise.
    
      #eof  ⇒ Boolean  (readonly)
      #eof?  ⇒ Boolean 
    
    Also known as: #eof?
  
Boolean  (readonly)
      #eof?  ⇒ Boolean 
    Returns true if strio is at end of file. The stringio must be opened for reading or an IOError will be raised.
    
      #eof  ⇒ Boolean  (readonly)
      #eof?  ⇒ Boolean 
    
  
Boolean  (readonly)
      #eof?  ⇒ Boolean 
    Alias for #eof.
    #lineno  ⇒ Integer  (rw)  
    #lineno=(integer)  ⇒ Integer  (rw)  
Manually sets the current line number to the given value. $. is updated only on the next read.
    
      #pos  ⇒ Integer  (rw)
      #tell  ⇒ Integer 
    
  
Integer  (rw)
      #tell  ⇒ Integer 
    Returns the current offset (in bytes) of strio.
    #pos=(integer)  ⇒ Integer  (rw)  
Seeks to the given position (in bytes) in strio.
    #string  ⇒ String  (rw)  
Returns underlying String object, the subject of ::IO.
    #string=(string)  ⇒ String  (rw)  
Changes underlying String object, the subject of ::IO.
    #tty?  ⇒ Boolean  (readonly)
  
Instance Method Details
    #binmode  ⇒ true   
#bytes
This is a deprecated alias for #each_byte.
#chars
This is a deprecated alias for #each_char.
    #close  ⇒ nil   
Closes strio.  The strio is unavailable for any further data operations; an IOError is raised if such an attempt is made.
    #close_read  ⇒ nil   
Closes the read end of a StringIO.  Will raise an IOError if the strio is not readable.
    #close_write  ⇒ nil   
Closes the write end of a StringIO.  Will raise an  IOError if the strio is not writeable.
#codepoints
This is a deprecated alias for #each_codepoint.
    
      #each(sep = $/) {|line| ... } ⇒ strio 
      #each(limit) {|line| ... } ⇒ strio 
      #each(sep, limit) {|line| ... } ⇒ strio 
      #each(...)  ⇒ Enumerator 
    
    Also known as: #each_line
  
strio 
      #each(limit) {|line| ... } ⇒ strio 
      #each(sep, limit) {|line| ... } ⇒ strio 
      #each(...)  ⇒ Enumerator 
    strio.each_line(sep=$/) {|line| block } -> strio
strio.each_line(limit) {|line| block }     -> strio
strio.each_line(sep,limit) {|line| block } -> strio
strio.each_line(...)                       -> anEnumeratorSee IO#each.
    
      #each_byte {|byte| ... } ⇒ strio 
      #each_byte  ⇒ Enumerator 
    
  
strio 
      #each_byte  ⇒ Enumerator 
    See IO#each_byte.
    
      #each_char {|char| ... } ⇒ strio 
      #each_char  ⇒ Enumerator 
    
  
strio 
      #each_char  ⇒ Enumerator 
    See IO#each_char.
    
      #each_codepoint {|c| ... } ⇒ strio 
      #each_codepoint  ⇒ Enumerator 
    
  
strio 
      #each_codepoint  ⇒ Enumerator 
    See IO#each_codepoint.
    
      #each(sep = $/) {|line| ... } ⇒ strio 
      #each(limit) {|line| ... } ⇒ strio 
      #each(sep, limit) {|line| ... } ⇒ strio 
      #each(...)  ⇒ Enumerator 
    
  
strio 
      #each(limit) {|line| ... } ⇒ strio 
      #each(sep, limit) {|line| ... } ⇒ strio 
      #each(...)  ⇒ Enumerator 
    Alias for #each.
    #external_encoding  ⇒ Encoding   
Returns the Encoding object that represents the encoding of the file. If strio is write mode and no encoding is specified, returns nil.
#fcntl
#fileno
#flush
#fsync
    #getbyte  ⇒ Fixnum?   
See IO#getbyte.
    #getc  ⇒ String?   
See IO#getc.
    
      #gets(sep = $/)  ⇒ String? 
      #gets(limit)  ⇒ String? 
      #gets(sep, limit)  ⇒ String? 
    
  
String? 
      #gets(limit)  ⇒ String? 
      #gets(sep, limit)  ⇒ String? 
    See IO#gets.
    #internal_encoding  ⇒ Encoding   
Returns the Encoding of the internal string if conversion is specified. Otherwise returns nil.
#isatty
    
      #length  ⇒ Integer 
      #size  ⇒ Integer 
    
    Also known as: #size
  
Integer 
      #size  ⇒ Integer 
    Returns the size of the buffer string.
#lines(*args)
This is a deprecated alias for #each_line.
#pid
    #putc(obj)  ⇒ Object   
See IO#putc.
    #read([length [, outbuf]])  ⇒ String, ...   
See IO#read.
    
      #readlines(sep = $/)  ⇒ Array 
      #readlines(limit)  ⇒ Array 
      #readlines(sep, limit)  ⇒ Array 
    
  
Array 
      #readlines(limit)  ⇒ Array 
      #readlines(sep, limit)  ⇒ Array 
    See IO#readlines.
    
      #reopen(other_StrIO)  ⇒ strio 
      #reopen(string, mode)  ⇒ strio 
    
  
strio 
      #reopen(string, mode)  ⇒ strio 
    Reinitializes strio with the given other_StrIO or string and mode (see StringIO#new).
    #rewind  ⇒ 0   
Positions strio to the beginning of input, resetting #lineno to zero.
    #seek(amount, whence = SEEK_SET)  ⇒ 0   
Seeks to a given offset amount in the stream according to the value of whence (see IO#seek).
    #set_encoding(ext_enc, [int_enc[, opt]])  ⇒ strio   
Specify the encoding of the StringIO as ext_enc. Use the default external encoding if ext_enc is nil. 2nd argument int_enc and optional hash opt argument are ignored; they are for API compatibility to ::IO.
    
      #length  ⇒ Integer 
      #size  ⇒ Integer 
    
  
Integer 
      #size  ⇒ Integer 
    Alias for #length.
    #sync  ⇒ true   
Returns true always.
#sync=
#tell
    #truncate(integer)  ⇒ 0   
Truncates the buffer string to at most integer bytes. The strio must be opened for writing.
    #ungetbyte(fixnum)  ⇒ nil   
See IO#ungetbyte
    #ungetc(string)  ⇒ nil   
Pushes back one character (passed as a parameter) onto strio such that a subsequent buffered read will return it. There is no limitation for multiple pushbacks including pushing back behind the beginning of the buffer string.
    
      #write(string)  ⇒ Integer 
      #syswrite(string)  ⇒ Integer 
    
  
Integer 
      #syswrite(string)  ⇒ Integer 
    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.