Class: StringIO

Inherits:
Data
  • Object
show all
Includes:
Enumerable
Defined in:
stringio.c

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#new(string = ""[, mode]) ⇒ Object

Creates new StringIO instance from with string and mode.



213
214
215
# File 'stringio.c', line 213

static VALUE
strio_initialize(argc, argv, self)
int argc;

Class Method Details

.open(string = ""[, mode]) {|strio| ... } ⇒ 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.

Yields:

  • (strio)


197
198
199
# File 'stringio.c', line 197

static VALUE
strio_s_open(argc, argv, klass)
int argc;

Instance Method Details

#<<Object

#binmodeObject

#closenil

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

Returns:

  • (nil)


380
381
382
# File 'stringio.c', line 380

static VALUE
strio_close(self)
VALUE self;

#close_readnil

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

Returns:

  • (nil)


399
400
401
# File 'stringio.c', line 399

static VALUE
strio_close_read(self)
VALUE self;

#close_writenil

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

Returns:

  • (nil)


418
419
420
# File 'stringio.c', line 418

static VALUE
strio_close_write(self)
VALUE self;

#closed?Boolean

Returns true if strio is completely closed, false otherwise.

Returns:

  • (Boolean)


436
437
438
# File 'stringio.c', line 436

static VALUE
strio_closed(self)
VALUE self;

#closed_read?Boolean

Returns true if strio is not readable, false otherwise.

Returns:

  • (Boolean)


451
452
453
# File 'stringio.c', line 451

static VALUE
strio_closed_read(self)
VALUE self;

#closed_write?Boolean

Returns true if strio is not writable, false otherwise.

Returns:

  • (Boolean)


466
467
468
# File 'stringio.c', line 466

static VALUE
strio_closed_write(self)
VALUE self;

#each(sep_string = $/) {|line| ... } ⇒ Object #each_line(sep_string = $/) {|line| ... } ⇒ Object

See IO#each.

Overloads:

  • #each(sep_string = $/) {|line| ... } ⇒ Object

    Yields:

    • (line)
  • #each_line(sep_string = $/) {|line| ... } ⇒ Object

    Yields:

    • (line)


950
951
952
# File 'stringio.c', line 950

static VALUE
strio_each(argc, argv, self)
int argc;

#each_byte {|byte| ... } ⇒ Object

See IO#each_byte.

Yields:

  • (byte)


693
694
695
# File 'stringio.c', line 693

static VALUE
strio_each_byte(self)
VALUE self;

#each(sep_string = $/) {|line| ... } ⇒ Object #each_line(sep_string = $/) {|line| ... } ⇒ Object

See IO#each.

Overloads:

  • #each(sep_string = $/) {|line| ... } ⇒ Object

    Yields:

    • (line)
  • #each_line(sep_string = $/) {|line| ... } ⇒ Object

    Yields:

    • (line)


950
951
952
# File 'stringio.c', line 950

static VALUE
strio_each(argc, argv, self)
int argc;

#eofBoolean #eof?Boolean

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

Overloads:

  • #eofBoolean

    Returns:

    • (Boolean)
  • #eof?Boolean

    Returns:

    • (Boolean)


483
484
485
# File 'stringio.c', line 483

static VALUE
strio_eof(self)
VALUE self;

#eofBoolean #eof?Boolean

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

Overloads:

  • #eofBoolean

    Returns:

    • (Boolean)
  • #eof?Boolean

    Returns:

    • (Boolean)


483
484
485
# File 'stringio.c', line 483

static VALUE
strio_eof(self)
VALUE self;

#fcntlObject

#filenoObject

#flushObject

#fsyncObject

#getcFixnum?

See IO#getc.

Returns:

  • (Fixnum, nil)


711
712
713
# File 'stringio.c', line 711

static VALUE
strio_getc(self)
VALUE self;

#gets(sep_string = $/) ⇒ String?

See IO#gets.

Returns:

  • (String, nil)


914
915
916
# File 'stringio.c', line 914

static VALUE
strio_gets(argc, argv, self)
int argc;

#initialize_copyObject

:nodoc:



493
494
495
# File 'stringio.c', line 493

static VALUE
strio_copy(copy, orig)
VALUE copy, orig;

#isattyObject

#sizeInteger

Returns the size of the buffer string.

Returns:

  • (Integer)


1205
1206
1207
# File 'stringio.c', line 1205

static VALUE
strio_size(self)
VALUE self;

#linenoInteger

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.

Returns:

  • (Integer)


521
522
523
# File 'stringio.c', line 521

static VALUE
strio_get_lineno(self)
VALUE self;

#lineno=(integer) ⇒ Integer

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

Returns:

  • (Integer)


535
536
537
# File 'stringio.c', line 535

static VALUE
strio_set_lineno(self, lineno)
VALUE self, lineno;

#pathObject

#pidObject

#posInteger #tellInteger

Returns the current offset (in bytes) of strio.

Overloads:

  • #posInteger

    Returns:

    • (Integer)
  • #tellInteger

    Returns:

    • (Integer)


583
584
585
# File 'stringio.c', line 583

static VALUE
strio_get_pos(self)
VALUE self;

#pos=(integer) ⇒ Integer

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

Returns:

  • (Integer)


596
597
598
# File 'stringio.c', line 596

static VALUE
strio_set_pos(self, pos)
VALUE self;

#printfObject

#putc(obj) ⇒ Object

See IO#putc.

Returns:

  • (Object)


1054
1055
1056
# File 'stringio.c', line 1054

static VALUE
strio_putc(self, ch)
VALUE self, ch;

#putsObject

#read([length [, buffer]]) ⇒ String?

See IO#read.

Returns:

  • (String, nil)


1087
1088
1089
# File 'stringio.c', line 1087

static VALUE
strio_read(argc, argv, self)
int argc;

#readcharFixnum

See IO#readchar.

Returns:

  • (Fixnum)


782
783
784
# File 'stringio.c', line 782

static VALUE
strio_readchar(self)
VALUE self;

#readline(sep_string = $/) ⇒ String

See IO#readline.

Returns:

  • (String)


932
933
934
# File 'stringio.c', line 932

static VALUE
strio_readline(argc, argv, self)
int argc;

#readlines(sep_string = $/) ⇒ Array

See IO#readlines.

Returns:

  • (Array)


971
972
973
# File 'stringio.c', line 971

static VALUE
strio_readlines(argc, argv, self)
int argc;

#reopen(other_StrIO) ⇒ Object #reopen(string, mode) ⇒ Object

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



563
564
565
# File 'stringio.c', line 563

static VALUE
strio_reopen(argc, argv, self)
int argc;

#rewind0

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

Returns:

  • (0)


618
619
620
# File 'stringio.c', line 618

static VALUE
strio_rewind(self)
VALUE self;

#seek(amount, whence = SEEK_SET) ⇒ 0

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

Returns:

  • (0)


636
637
638
# File 'stringio.c', line 636

static VALUE
strio_seek(argc, argv, self)
int argc;

#sizeInteger

Returns the size of the buffer string.

Returns:

  • (Integer)


1205
1206
1207
# File 'stringio.c', line 1205

static VALUE
strio_size(self)
VALUE self;

#stringString

Returns underlying String object, the subject of IO.

Returns:

  • (String)


345
346
347
# File 'stringio.c', line 345

static VALUE
strio_get_string(self)
VALUE self;

#string=(string) ⇒ String

Changes underlying String object, the subject of IO.

Returns:

  • (String)


358
359
360
# File 'stringio.c', line 358

static VALUE
strio_set_string(self, string)
VALUE self, string;

#synctrue

Returns true always.

Returns:

  • (true)


674
675
676
# File 'stringio.c', line 674

static VALUE
strio_get_sync(self)
VALUE self;

#sync=Object

#sysread(integer[, outbuf]) ⇒ String

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

Returns:

  • (String)


1167
1168
1169
# File 'stringio.c', line 1167

static VALUE
strio_sysread(argc, argv, self)
int argc;

#syswriteObject

#tellObject

#truncate(integer) ⇒ 0

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

Returns:

  • (0)


1223
1224
1225
# File 'stringio.c', line 1223

static VALUE
strio_truncate(self, len)
VALUE self, len;

#tty?Boolean

Returns:

  • (Boolean)

#ungetc(integer) ⇒ nil

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.

Returns:

  • (nil)


754
755
756
# File 'stringio.c', line 754

static VALUE
strio_ungetc(self, ch)
VALUE self, ch;

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

Overloads:

  • #write(string) ⇒ Integer

    Returns:

    • (Integer)
  • #syswrite(string) ⇒ Integer

    Returns:

    • (Integer)


995
996
997
# File 'stringio.c', line 995

static VALUE
strio_write(self, str)
VALUE self, str;