method
putc
v1_8_6_287 -
Show latest stable
- Class:
StringIO
putc(p1)public
See <a href="/ruby/IO/putc">IO#putc</a>.
/*
* call-seq:
* strio.putc(obj) -> obj
*
* See IO#putc.
*/
static VALUE
strio_putc(self, ch)
VALUE self, ch;
{
struct StringIO *ptr = writable(StringIO(self));
int c = NUM2CHR(ch);
long olen;
check_modifiable(ptr);
olen = RSTRING(ptr->string)->len;
if (ptr->flags & FMODE_APPEND) {
ptr->pos = olen;
}
strio_extend(ptr, ptr->pos, 1);
RSTRING(ptr->string)->ptr[ptr->pos++] = c;
OBJ_INFECT(ptr->string, self);
return ch;
} Related methods
- Instance methods
- <<
- binmode
- close
- close_read
- close_write
- closed?
- closed_read?
- closed_write?
- each
- each_byte
- each_line
- eof
- eof
- eof?
- eof?
- fcntl
- fileno
- flush
- fsync
- getc
- gets
- initialize_copy
- isatty
- length
- lineno
- lineno=
- path
- pid
- pos
- pos
- pos=
- printf
- putc
- puts
- read
- readchar
- readline
- readline
- readlines
- reopen
- rewind
- rewind
- seek
- seek
- size
- string
- string=
- sync
- sync=
- sysread
- syswrite
- tell
- truncate
- tty?
- ungetc
- write
- Class methods
- new
- new
- open