class Dire::Dir

Public Class Methods

invalid_path_handler=(lambda) click to toggle source
# File lib/dire/dir.rb, line 11
def self.invalid_path_handler= lambda
  @@invalid_path_handler = lambda
end

Public Instance Methods

dirs() click to toggle source
# File lib/dire/dir.rb, line 15
def dirs
  nodes.select { |i| i.absolute_path.directory? }
end
files() click to toggle source
# File lib/dire/dir.rb, line 19
def files
  nodes.select { |i| not i.absolute_path.directory? }
end
list() click to toggle source
# File lib/dire/dir.rb, line 23
def list
  dirs + files
end
root?() click to toggle source
# File lib/dire/dir.rb, line 27
def root?
  not parent
end
validate!() click to toggle source
Calls superclass method
# File lib/dire/dir.rb, line 31
def validate!
  super && validate_type!('directory')
end

Private Instance Methods

nodes() click to toggle source
# File lib/dire/dir.rb, line 37
def nodes
  return @nodes if @nodes

  @nodes = absolute_path.glob '*', ::File::FNM_DOTMATCH
  @nodes = @nodes.each_with_object(Array.new) do |path, nodes|
    next if ignore? path

    if absolute_path.to_s < path.to_s
      begin
        nodes.push get(path)
      rescue Dire::Error::InvalidLink
        @@invalid_link_handler.(root, nodes, path)
      rescue Dire::Error::InvalidPath
        @@invalid_path_handler.(root, nodes, path)
      end
    end
  end
end