Method: Path#each_filename

Defined in:
lib/epath/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".

Yield Parameters:

  • filename (String)


78
79
80
81
82
83
# File 'lib/epath/parts.rb', line 78

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