Fixes Dir.children and Dir.each_child

The two methods exclude "." and "..".
This commit is contained in:
dearblue
2024-05-10 21:54:59 +09:00
parent dcee404ebb
commit 12030b3f41
+17 -2
View File
@@ -8,7 +8,13 @@ class Dir
self
end
alias each_child each
def each_child(&block)
while s = self.read
block.call(s) unless s == "." || s == ".."
end
self
end
alias pos tell
alias pos= seek
@@ -22,7 +28,16 @@ class Dir
end
a
end
alias children entries
def children(path)
a = []
self.open(path) do |d|
while s = d.read
a << s unless s == "." || s == ".."
end
end
a
end
def foreach(path, &block)
self.open(path) do |d|