Class: Build::Files::Difference

Inherits:
List
  • Object
show all
Defined in:
lib/build/files/difference.rb

Constant Summary

Constants inherited from List

List::NONE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from List

#+, #==, coerce, #copy, #create, #delete, #empty?, #exist?, #intersects?, #map, #roots, #to_paths, #to_s, #touch, #with

Constructor Details

#initialize(list, excludes) ⇒ Difference

Returns a new instance of Difference.



11
12
13
14
# File 'lib/build/files/difference.rb', line 11

def initialize(list, excludes)
	@list = list
	@excludes = excludes
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



16
17
18
# File 'lib/build/files/difference.rb', line 16

def files
  @files
end

Instance Method Details

#-(list) ⇒ Object



33
34
35
# File 'lib/build/files/difference.rb', line 33

def -(list)
	self.class.new(@list, Composite.new(@excludes, list))
end

#eachObject



25
26
27
28
29
30
31
# File 'lib/build/files/difference.rb', line 25

def each
	return to_enum(:each) unless block_given?
	
	@list.each do |path|
		yield path unless @excludes.include?(path)
	end
end

#freezeObject



18
19
20
21
22
23
# File 'lib/build/files/difference.rb', line 18

def freeze
	@list.freeze
	@excludes.freeze
	
	super
end

#include?(path) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/build/files/difference.rb', line 37

def include?(path)
	@list.includes?(path) and !@excludes.include?(path)
end

#inspectObject



45
46
47
# File 'lib/build/files/difference.rb', line 45

def inspect
	"<Difference #{@files.inspect} - #{@excludes.inspect}>"
end

#rebase(root) ⇒ Object



41
42
43
# File 'lib/build/files/difference.rb', line 41

def rebase(root)
	self.class.new(@files.collect{|list| list.rebase(root)}, [root])
end