Skip to content

Commit

Permalink
Renamed Dir.foreach to Dir.each_entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Aug 10, 2017
1 parent b7be267 commit 705ac1e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/dir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Dir

# Calls the block once for each entry in the named directory,
# passing the filename of each entry as a parameter to the block.
def self.foreach(dirname)
def self.each_entry(dirname)
Dir.open(dirname) do |dir|
dir.each do |filename|
yield filename
Expand All @@ -148,7 +148,7 @@ class Dir
# Returns an array containing all of the filenames in the given directory.
def self.entries(dirname) : Array(String)
entries = [] of String
foreach(dirname) do |filename|
each_entry(dirname) do |filename|
entries << filename
end
entries
Expand All @@ -158,7 +158,7 @@ class Dir
# directory, passing the filename of each entry as a parameter to the block.
def self.each_child(dirname)
excluded = {".", ".."}
foreach(dirname) do |filename|
each_entry(dirname) do |filename|
yield filename unless excluded.includes?(filename)
end
end
Expand Down Expand Up @@ -197,7 +197,7 @@ class Dir
def self.empty?(path) : Bool
raise Errno.new("Error determining size of '#{path}'") unless exists?(path)

foreach(path) do |f|
each_entry(path) do |f|
return false unless {".", ".."}.includes?(f)
end
true
Expand Down

0 comments on commit 705ac1e

Please sign in to comment.