Method: Path#each_filename

Defined in:
lib/path/parts.rb

#each_filename {|filename| ... } ⇒ Object

Iterates over each component of the path.

Path.new("/usr/bin/ruby").each_filename { |filename| ... }
  # yields "usr", "bin", and "ruby".

Returns an Enumerator if no block was given.

Yield Parameters:

  • filename (String)


90
91
92
93
94
95
# File 'lib/path/parts.rb', line 90

def each_filename
  return to_enum(__method__) unless block_given?
  _, names = split_names(@path)
  names.each { |filename| yield filename }
  nil
end