Method: Dir#each

Defined in:
dir.c

#each {|filename| ... } ⇒ Dir #eachObject

Calls the block once for each entry in this directory, passing the filename of each entry as a parameter to the block.

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

d = Dir.new("testdir")
d.each  {|x| puts "Got #{x}" }

produces:

Got .
Got ..
Got config.h
Got main.rb

Overloads:

  • #each {|filename| ... } ⇒ Dir

    Yields:

    • (filename)

    Returns:

[View source]

798
799
800
801
802
803
# File 'dir.c', line 798

static VALUE
dir_each(VALUE dir)
{
    RETURN_ENUMERATOR(dir, 0, 0);
    return dir_each_entry(dir, dir_yield, Qnil, FALSE);
}