Method: Pathname#find_dirs

Defined in:
lib/pleasant_path/pathname.rb

#find_dirs {|descendent| ... } ⇒ self #find_dirsEnumerator<Pathname>

Iterates over all (recursive) descendent directories of the directory indicated by the Pathname. Iterated Pathnames are prefixed by the original Pathname, and are in depth-first order.

If a block is given, each descendent Pathname is yielded, and this method returns the original Pathname. Otherwise, an Enumerator is returned.

Overloads:

  • #find_dirs {|descendent| ... } ⇒ self

    Yield Parameters:

    Returns:

    • (self)
  • #find_dirsEnumerator<Pathname>

    Returns:

See Also:



149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/pleasant_path/pathname.rb', line 149

def find_dirs
  return to_enum(__method__) unless block_given?

  self.find do |path|
    if path.file?
      Find.prune
    elsif path != self
      yield path
    end
  end

  self
end