Class: Pathname

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

### Methods

/ [] empty? glob glob_first home null root rootname split_root work

### External Aliases

+ | -> | /
| Try to get this into standard Pathname class.

### Public Class methods

/(path)

Active path separator.

      p1 = Pathname.new('/')
      p2 = p1 / 'usr' / 'share'   #=> Pathname:/usr/share

[Source]

    # File lib/more/facets/pathname.rb, line 41
      def self./(path)
        new(path)
      end

[](path)

Alternate to Pathname#new.

      Pathname['/usr/share']

[Source]

    # File lib/more/facets/pathname.rb, line 32
      def self.[](path)
        new(path)
      end

home()

Home constant for building paths from root directory onward.

TODO: Pathname#home needs to be more robust.

[Source]

    # File lib/more/facets/pathname.rb, line 54
      def self.home
        Pathname.new('~')
      end

null()

Platform dependent null device.

[Source]

    # File lib/more/facets/pathname.rb, line 71
      def self.null
        case RUBY_PLATFORM
        when /mswin/i
          'NUL'
        when /amiga/i
          'NIL:'
        when /openvms/i
          'NL:'
        else
          '/dev/null'
        end
      end

root()

Root constant for building paths from root directory onward.

[Source]

    # File lib/more/facets/pathname.rb, line 46
      def self.root
        Pathname.new('/')
      end

work()

Work constant for building paths from root directory onward.

[Source]

    # File lib/more/facets/pathname.rb, line 60
      def self.work
        Pathname.new('.')
      end

### Public Instance methods

empty?()

[Source]

    # File lib/more/facets/pathname.rb, line 155
      def empty?
        Dir.glob(::File.join(self.to_s, '*')).empty?
      end

glob(match, *opts)

[Source]

    # File lib/more/facets/pathname.rb, line 128
      def glob(match, *opts)
        flags = 0
        opts.each do |opt|
          case opt when Symbol, String
            flags += File.const_get("FNM_#{opt}".upcase)
          else
            flags += opt
          end
        end
        Dir.glob(::File.join(self.to_s, match), flags).collect{ |m| self.class.new(m) }
      end

glob_first(match, *opts)

[Source]

    # File lib/more/facets/pathname.rb, line 141
      def glob_first(match, *opts)
        flags = 0
        opts.each do |opt|
          case opt when Symbol, String
            flags += ::File.const_get("FNM_#{opt}".upcase)
          else
            flags += opt
          end
        end
        file = ::Dir.glob(::File.join(self.to_s, match), flags).first
        file ? self.class.new(file) : nil
      end

rootname()

[Source]

    # File lib/more/facets/pathname.rb, line 85
      def rootname
        self.class.new(File.rootname(to_s))
      end

split_root()

[Source]

    # File lib/more/facets/pathname.rb, line 122
      def split_root
        head, tail = *::File.split_root(to_s)
        [self.class.new(head), self.class.new(tail)]
      end

[Validate]