Actions
Feature #13969
closedDir#each_child
Status:
Closed
Assignee:
-
Target version:
-
Description
Dir has class method pairs: Dir.entries
/ Dir.children
, Dir.foreach
/ Dir.each_child
.
But instance method is Dir#each
only.
How about adding Dir#each_child
?
Updated by znz (Kazuhiro NISHIYAMA) about 7 years ago
- Related to Feature #11302: Dir.entries and Dir.foreach without [".", ".."] added
Updated by nobu (Nobuyoshi Nakada) about 7 years ago
diff --git a/dir.c b/dir.c
index 44d309195c..242afa131d 100644
--- a/dir.c
+++ b/dir.c
@@ -2743,6 +2743,13 @@ dir_s_each_child(int argc, VALUE *argv, VALUE io)
return Qnil;
}
+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)
{
@@ -3104,6 +3111,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);
Updated by matz (Yukihiro Matsumoto) almost 7 years ago
Agreed.
Matz.
Updated by nobu (Nobuyoshi Nakada) almost 7 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r62022.
dir.c: Dir#each_child
- dir.c (dir_each_child_m): new instance methods Dir#each_child
and Dir#children. [Feature #13969]
Updated by nobu (Nobuyoshi Nakada) over 6 years ago
- Related to Feature #12010: Exclude dot and dotdot from Dir#each added
Actions
Like0
Like0Like0Like0Like0Like0