method
ungetbyte
v2_4_6 -
Show latest stable
- Class:
StringIO
ungetbyte(p1)public
See IO#ungetbyte
static VALUE
strio_ungetbyte(VALUE self, VALUE c)
{
struct StringIO *ptr = readable(self);
char buf[1], *cp = buf;
long cl = 1;
check_modifiable(ptr);
if (NIL_P(c)) return Qnil;
if (FIXNUM_P(c)) {
buf[0] = (char)FIX2INT(c);
return strio_unget_bytes(ptr, buf, 1);
}
else {
SafeStringValue(c);
cp = RSTRING_PTR(c);
cl = RSTRING_LEN(c);
if (cl == 0) return Qnil;
strio_unget_bytes(ptr, cp, cl);
RB_GC_GUARD(c);
return Qnil;
}
} 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