class Build::Files::Directory

Represents a directory of files.

def self.join(*args)

@returns [Directory] A new directory at the joined path.
@parameter args [Array(String)] The path components to join.
Join path components and create a directory.
def self.join(*args)
	self.new(Path.join(*args))
end

def each

@parameter path [Path] The current file path.
@yields {|path| ...} Each file path in the directory.
Iterate over all files in the directory recursively.
def each
	return to_enum(:each) unless block_given?
	
	# We match both normal files with * and dotfiles with .?*
	Dir.glob(@root + "**/{*,.?*}") do |path|
		yield Path.new(path, @root)
	end
end

def eql?(other)

@returns [Boolean] True if both directories have the same root.
@parameter other [Directory] The other directory to compare.
Check equality with another directory.
def eql?(other)
	self.class.eql?(other.class) and @root.eql?(other.root)
end

def hash

@returns [Integer] The hash value based on the root.
Compute the hash value for this directory.
def hash
	@root.hash
end

def include?(path)

@returns [Boolean] True if the path is within this directory.
@parameter path [Path] The path to check.
Check if the directory includes a specific path.
def include?(path)
	# Would be true if path is a descendant of full_path.
	path.start_with?(@root)
end

def initialize(root)

@parameter root [Path | String] The root path of the directory.
Initialize a directory with a root path.
def initialize(root)
	@root = root
end

def rebase(root)

@returns [Directory] A new directory with the rebased root.
@parameter root [Path] The new root path.
Rebase the directory to a new root.
def rebase(root)
	self.class.new(@root.rebase(root))
end

def root

@returns [Path] The root path.
Get the root path of the directory.
def root
	@root
end

def roots

@returns [Array(Path)] An array containing the single root path.
Get the root paths as an array.
def roots
	[root]
end

def to_path

@returns [Path] The root path.
Convert the directory to a path object.
def to_path
	@root
end

def to_s

@returns [String] The root path as a string.
Convert the directory to a string.
def to_s
	to_str
end

def to_str

@returns [String] The root path as a string.
Convert the directory to a string for use as a command argument.
def to_str
	@root.to_str
end