End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Pathname#each_filename
each_filename() { |filename| ... }
ext/pathname/lib/pathname.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/ext/pathname/lib/pathname.rb, line 263
def each_filename # :yield: filename
return to_enum(__method__) unless block_given?
_, names = split_names(@path)
names.each {|filename| yield filename }
nil
end
Iterates over each component of the path.
Pathname.new("/usr/bin/ruby").each_filename {|filename| ... }
# yields "usr", "bin", and "ruby".
Returns an Enumerator if no block was given.
enum = Pathname.new("/usr/bin/ruby").each_filename
# ... do stuff ...
enum.each { |e| ... }
# yields "usr", "bin", and "ruby".