Class | Pathname
In: | lib/standard/facets/pathname.rb
Parent: | Object

### Methods

/ [] empty? glob glob_first glob_relative home include? null outofdate? root rootname split_root uptodate? visit work

### External Aliases

to_s | -> | to_str
| Alias to_s to to_str when to_str is not defined.
+ | -> | /
| Try to get this into standard Pathname class.

### Public Class methods

/(path)

Start a path. Another alias for new.

      Pathname / 'usr'

[](path)

Alternate to Pathname#new.

      Pathname['/usr/share']

home()

Home constant for building paths from root directory onward.

TODO: Pathname#home needs to be more robust.

null()

Platform dependent null device.

CREDIT Daniel Burger

root()

Root constant for building paths from root directory onward.

work()

Work constant for building paths from root directory onward.

### Public Instance methods

empty?()
glob(match, *opts)

Glob pathnames.

glob_first(match, *opts)

Return the first glob match.

DEPRECATE: While slightly faster then glob().first, not really worth it unless this can be rewritten to shortcut on first match (using fnmatch?). In wich case, is there a better name for this method?

glob_relative(match, *opts)

Return globbed matches with pathnames relative to the current pathname.

include?(pattern,*opts)

Does a directory contain a matching entry? Or if the pathname is a file, same as fnmatch.

outofdate?(*sources)
rootname()
split_root()
uptodate?(*sources)
visit => yield each file
visit(all: true) => yield visited directories as well
visit(hidden: true) => yield hidden files and directories as well

Recursively visit a directory located by its path, yielding each resource as its full matching pathname object. If called on a file, yield the file.

Example use case:

      # Locate any file but *.haml within app/**/*
      Pathname.new("app").visit do |f|
        next unless f.to_s =~ /\.haml$/
        f
      end

TODO: Use map instead of each ?

CREDIT: Jean-Denis Vauguet

[Validate]