class Build::Files::List

A list of paths, where #each yields instances of Path.

def self.coerce(arg)

def self.coerce(arg)
	if arg.kind_of? self
		arg
	else
		Paths.new(arg)
	end
end

def +(list)

Create a composite list out of two other lists:
def +(list)
	Composite.new([self, list])
end

def -(list)

def -(list)
	Difference.new(self, list)
end

def ==(other)

This isn't very efficient, but it IS generic.
def ==(other)
	if self.class == other.class
		self.eql?(other)
	elsif other.kind_of? self.class
		self.to_a.sort == other.to_a.sort
	else
		super
	end
end

def create

Recursively create paths for all listed paths.
def create
	each(&:create)
end

def delete

Recursively delete all paths and all contents within those paths.
def delete
	each(&:delete)
end

def exist?

Check that all files listed exist.
def exist?
	all?(&:exist?)
end

def intersects? other

Does this list of files include the path of any other?
def intersects? other
	other.any?{|path| include?(path)}
end

def map

def map
	Paths.new(super)
end

def rebase(root)

def rebase(root)
	Paths.new(self.collect{|path| path.rebase(root)}, [root])
end

def roots

def roots
	collect{|path| path.root}.sort.uniq
end

def to_paths

def to_paths
	Paths.new(each.to_a)
end

def to_s

def to_s
	inspect
end

def touch

Touch all listed files.
def touch
	each(&:touch)
end

def with(**options)

def with(**options)
	return to_enum(:with, **options) unless block_given?
	
	paths = []
	
	self.each do |path|
		updated_path = path.with(**options)
		
		yield path, updated_path
		
		paths << updated_path
	end
	
	return Paths.new(paths)
end