summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-24 07:15:55 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-24 07:15:55 (GMT)
commit6a3a7e9114c3ede47d15f0d2a73f392cfcdd1ea7 (patch)
tree81666af8b33f71df8c624f4940df197a70cbc692 /dir.c
parentf7210deb82c57e736ee8e4db2ff43cba17cb5829 (diff)
dir.c: Dir#each_child
* dir.c (dir_each_child_m): new instance methods Dir#each_child and Dir#children. [Feature #13969] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index 26cc122..71eb935 100644
--- a/dir.c
+++ b/dir.c
@@ -2860,6 +2860,13 @@ dir_s_each_child(int argc, VALUE *argv, VALUE io)
}
static VALUE
+dir_each_child_m(VALUE dir)
+{
+ RETURN_ENUMERATOR(dir, 0, 0);
+ return dir_each_entry(dir, dir_yield, Qnil, TRUE);
+}
+
+static VALUE
dir_collect_children(VALUE dir)
{
VALUE ary = rb_ary_new();
@@ -3212,6 +3219,8 @@ Init_Dir(void)
rb_define_method(rb_cDir,"inspect", dir_inspect, 0);
rb_define_method(rb_cDir,"read", dir_read, 0);
rb_define_method(rb_cDir,"each", dir_each, 0);
+ rb_define_method(rb_cDir,"each_child", dir_each_child_m, 0);
+ rb_define_method(rb_cDir,"children", dir_collect_children, 0);
rb_define_method(rb_cDir,"rewind", dir_rewind, 0);
rb_define_method(rb_cDir,"tell", dir_tell, 0);
rb_define_method(rb_cDir,"seek", dir_seek, 1);