Method: Dir.each_child

Defined in:
dir.c

.each_child(dirname) {|filename| ... } ⇒ nil .each_child(dirname, encoding: enc) {|filename| ... } ⇒ nil .each_child(dirname) ⇒ Object .each_child(dirname, encoding: enc) ⇒ Object

Calls the block once for each entry except for “.” and “..” in the named directory, passing the filename of each entry as a parameter to the block.

If no block is given, an enumerator is returned instead.

Dir.each_child("testdir") {|x| puts "Got #{x}" }

produces:

Got config.h
Got main.rb

Overloads:

  • .each_child(dirname) {|filename| ... } ⇒ nil

    Yields:

    • (filename)

    Returns:

    • (nil)
  • .each_child(dirname, encoding: enc) {|filename| ... } ⇒ nil

    Yields:

    • (filename)

    Returns:

    • (nil)


3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
# File 'dir.c', line 3070

static VALUE
dir_s_each_child(int argc, VALUE *argv, VALUE io)
{
    VALUE dir;

    RETURN_ENUMERATOR(io, argc, argv);
    dir = dir_open_dir(argc, argv);
    rb_ensure(dir_each_child, dir, dir_close, dir);
    return Qnil;
}