summaryrefslogtreecommitdiff
path: root/ext/stringio
diff options
context:
space:
mode:
Diffstat (limited to 'ext/stringio')
-rw-r--r--ext/stringio/stringio.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 6b867084dfe..fc589ef55d4 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -614,6 +614,9 @@ static VALUE
strio_each_byte(VALUE self)
{
struct StringIO *ptr = readable(StringIO(self));
+
+ RETURN_ENUMERATOR(self, 0, 0);
+
while (ptr->pos < RSTRING_LEN(ptr->string)) {
char c = RSTRING_PTR(ptr->string)[ptr->pos++];
rb_yield(CHR2FIX(c));
@@ -926,6 +929,8 @@ strio_each(int argc, VALUE *argv, VALUE self)
struct StringIO *ptr = StringIO(self);
VALUE line;
+ RETURN_ENUMERATOR(self, argc, argv);
+
while (!NIL_P(line = strio_getline(argc, argv, readable(ptr)))) {
rb_yield(line);
}
@@ -1233,7 +1238,9 @@ Init_stringio()
rb_define_method(StringIO, "each", strio_each, -1);
rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
+ rb_define_method(StringIO, "bytes", strio_each_byte, -1);
rb_define_method(StringIO, "each_line", strio_each, -1);
+ rb_define_method(StringIO, "lines", strio_each, -1);
rb_define_method(StringIO, "getc", strio_getc, 0);
rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
rb_define_method(StringIO, "readchar", strio_readchar, 0);