method
putc
v2_6_3 -
Show latest stable
- Class:
StringIO
putc(p1)public
See IO#putc.
static VALUE
strio_putc(VALUE self, VALUE ch)
{
struct StringIO *ptr = writable(self);
VALUE str;
check_modifiable(ptr);
if (RB_TYPE_P(ch, T_STRING)) {
str = rb_str_substr(ch, 0, 1);
}
else {
char c = NUM2CHR(ch);
str = rb_str_new(&c, 1);
}
strio_write(self, str);
return ch;
} Related methods
- Instance methods
- binmode
- bytes
- chars
- close
- close_read
- close_write
- closed?
- closed_read?
- closed_write?
- codepoints
- each
- each_byte
- each_char
- each_codepoint
- each_line
- eof
- eof?
- external_encoding
- fcntl
- fileno
- flush
- fsync
- getbyte
- getc
- gets
- initialize_copy
- internal_encoding
- isatty
- length
- lineno
- lineno=
- lines
- pid
- pos
- pos=
- putc
- read
- readlines
- reopen
- rewind
- seek
- set_encoding
- size
- string
- string=
- sync
- sync=
- tell
- truncate
- tty?
- ungetbyte
- ungetc
- write
- Class methods
- new
- open