Sha256: 5fba46f4efd517929e665962c4894a088d8636e9138ef803ac0af328fa6c438a

Contents?: true

Size: 819 Bytes

Versions: 2

Compression:

Stored size: 819 Bytes

Contents

require 'facets/pathname'

class Pathname

  # Like directory? but return self if true, otherwise nil.
  def dir?
    directory? ? self : nil
  end

# Already in Facets
#
#    def glob(*opts)
#      flags = 0
#      opts.each do |opt|
#        case opt when Symbol, String
#          flags += File.const_get("FNM_#{opt}".upcase)
#        else
#          flags += opt
#        end
#      end
#      self.class.glob(self.to_s, flags).collect{ |path| self.class.new(path) }
#    end
#
#    #
#    def first(*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 = self.class.glob(self.to_s, flags).first
#      file ? self.class.new(file) : nil
#    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ratch-1.0.0 lib/ratch/core_ext/pathname.rb
ratch-1.1.0 lib/ratch/core_ext/pathname.rb