Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
StringScanner#peek_byte
peek_byte
ext/strscan/strscan.c
View on GitHub ↗
static VALUE
strscan_peek_byte(VALUE self)
{
struct strscanner *p;
GET_SCANNER(self, p);
if (EOS_P(p))
return Qnil;
return INT2FIX((unsigned char)*CURPTR(p));
}
Peeks at the current byte and returns it as an integer.
Example
s = StringScanner.new('ab') s.peek_byte # => 97