Class Pathname
In: lib/standard/facets/pathname/rootname.rb
lib/standard/facets/pathname/op_div.rb
lib/standard/facets/pathname/visit.rb
lib/standard/facets/pathname/chdir.rb
lib/standard/facets/pathname/readline.rb
lib/standard/facets/pathname/safe.rb
lib/standard/facets/pathname/empty.rb
lib/standard/facets/pathname/split_root.rb
lib/standard/facets/pathname/work.rb
lib/standard/facets/pathname/to_str.rb
lib/standard/facets/pathname/root.rb
lib/standard/facets/pathname/outofdate.rb
lib/standard/facets/pathname/uptodate.rb
lib/standard/facets/pathname/op_fetch.rb
lib/standard/facets/pathname/exists.rb
lib/standard/facets/pathname/home.rb
lib/standard/facets/pathname/glob.rb
lib/standard/facets/pathname/null.rb
Parent: Object

Methods

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

External Aliases

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

Returns [String]

exist? -> exists?
  Pluralized alias for `exist?` method.

Public Class methods

Start a path. Another alias for new.

  Pathname / 'usr'

Alternate to Pathname#new.

  Pathname['/usr/share']

Returns [Pathname]

Home constant for building paths from root directory onward.

TODO: Pathname#home needs to be more robust.

Returns [Pathname]

Platform dependent null device.

CREDIT: Daniel Burger

Root constant for building paths from root directory onward.

Returns [Pathname]

Work constant for building paths from root directory onward.

Returns [Pathname]

Public Instance methods

Change current working directory of the process to the given path

See Dir.chdir

CREDIT: Ryan Duryea

Is a directory path empty?

Returns [Boolean]

Glob pathnames.

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?

Return globbed matches with pathnames relative to the current pathname.

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

TODO: Move to own file? Better name?

Returns [Pathname]

Is a path out of date relative a set of source files.

Returns [Boolean]

Reads the first line of the file

Captures the best practice from this post at stack overflow: stackoverflow.com/questions/1490138/reading-the-first-line-of-a-file-in-ruby

Credit: Ryan Duryea

Is a path reasonably safe?

Do not mistake this for a perfect solution!

Returns [Boolean]

Is a path up to date relative to a set of source files?

Returns [Boolean]

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.

Examples

    # 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]