End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Dir.open
open(name, encoding: nil) { |dir| ... }
dir.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/dir.rb, line 14
def self.open(name, encoding: nil, &block)
dir = Primitive.dir_s_open(name, encoding)
if block
begin
yield dir
ensure
Primitive.dir_s_close(dir)
end
else
dir
end
end
Dir.open( string ) -> aDir
Dir.open( string, encoding: enc ) -> aDir
Dir.open( string ) {| aDir | block } -> anObject
Dir.open( string, encoding: enc ) {| aDir | block } -> anObject
The optional encoding keyword argument specifies the encoding of the directory. If not specified, the filesystem encoding is used.
With no block, open is a synonym for Dir::new. If a block is present, it is passed aDir as a parameter. The directory is closed at the end of the block, and Dir::open returns the value of the block.