class Build::Files::Glob

Represents a glob pattern for matching files.

def each(&block)

Enumerate all paths matching the pattern.
def each(&block)
	return to_enum unless block_given?
	
	::Dir.glob(full_pattern, ::File::FNM_DOTMATCH) do |path|
		# Ignore `.` and `..` entries.
		next if path =~ /\/..?$/
		
		yield Path.new(path, @root)
	end
end

def eql?(other)

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

def full_pattern

@returns [String] The complete glob pattern.
Get the full pattern including the root path.
def full_pattern
	Path.join(@root, @pattern)
end

def hash

@returns [Integer] The hash value based on root and pattern.
Compute the hash value for this glob.
def hash
	[@root, @pattern].hash
end

def include?(path)

@returns [Boolean] True if the path matches the pattern.
@parameter path [Path] The path to check.
Check if a path matches this glob pattern.
def include?(path)
	File.fnmatch(full_pattern, path)
end

def initialize(root, pattern)

@parameter pattern [String] The glob pattern to match.
@parameter root [Path] The root directory for the glob.
Initialize a glob with a root path and pattern.
def initialize(root, pattern)
	@root = root
	@pattern = pattern
end

def inspect

@returns [String] A debug string showing the full pattern.
Generate a string representation for debugging.
def inspect
	"<Glob #{full_pattern.inspect}>"
end

def rebase(root)

@returns [Glob] A new glob with the same pattern under the new root.
@parameter root [Path] The new root path.
Rebase the glob to a new root.
def rebase(root)
	self.class.new(root, @pattern)
end

def roots

@returns [Array(Path)] An array containing the root path.
Get the root paths for this glob.
def roots
	[@root]
end