class

Dir

Inherits Iterable < Enumerable < Reference < Object

Objects of class Dir are directory streams representing directories in the underlying file system. They provide a variety of ways to list directories and their contents.

The directory used in these examples contains the two regular files (config.h and main.rb), the parent directory (..), and the directory itself (.).

See also: File.

Class methods

mktmpdir(prefix = "c")

Creates a new temporary directory

Dir.mktmpdir # => "/tmp/c.a56b2F"
Source
mktmpdir(prefix = "c", &)

Creates a new temporary directory within the lifecycle of the given block and destroys it, and its content, later on.

Dir.mktmpdir do |dir|
  puts dir
=> "/tmp/c.a56b2F"
end
Source
tmpdir

Returns the tmp dir

Dir.tmpdir # => "/tmp"
Source