Class: Build::Files::Composite
- Inherits:
-
List
- Object
- List
- Build::Files::Composite
show all
- Defined in:
- lib/build/files/composite.rb
Constant Summary
Constants inherited
from List
List::NONE
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from List
#-, #==, coerce, #create, #delete, #exist?, #intersects?, #map, #to_s, #touch, #with
Constructor Details
#initialize(files, roots = nil) ⇒ Composite
Returns a new instance of Composite.
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/build/files/composite.rb', line 26
def initialize(files, roots = nil)
@files = []
files.each do |list|
if list.kind_of? Composite
@files += list.files
elsif List.kind_of? List
@files << list
else
@files << Paths.new(list)
end
end
@files.freeze
@roots = roots
end
|
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
44
45
46
|
# File 'lib/build/files/composite.rb', line 44
def files
@files
end
|
Instance Method Details
#+(list) ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/build/files/composite.rb', line 72
def +(list)
if list.kind_of? Composite
self.class.new(@files + list.files)
else
self.class.new(@files + [list])
end
end
|
#each ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/build/files/composite.rb', line 52
def each
return to_enum(:each) unless block_given?
@files.each do |files|
files.each{|path| yield path}
end
end
|
#eql?(other) ⇒ Boolean
64
65
66
|
# File 'lib/build/files/composite.rb', line 64
def eql?(other)
self.class.eql?(other.class) and @files.eql?(other.files)
end
|
#freeze ⇒ Object
46
47
48
49
50
|
# File 'lib/build/files/composite.rb', line 46
def freeze
self.roots
super
end
|
#hash ⇒ Object
68
69
70
|
# File 'lib/build/files/composite.rb', line 68
def hash
@files.hash
end
|
#include?(path) ⇒ Boolean
80
81
82
|
# File 'lib/build/files/composite.rb', line 80
def include?(path)
@files.any? {|list| list.include?(path)}
end
|
#inspect ⇒ Object
92
93
94
|
# File 'lib/build/files/composite.rb', line 92
def inspect
"<Composite #{@files.inspect}>"
end
|
#rebase(root) ⇒ Object
84
85
86
|
# File 'lib/build/files/composite.rb', line 84
def rebase(root)
self.class.new(@files.collect{|list| list.rebase(root)}, [root])
end
|
#roots ⇒ Object
60
61
62
|
# File 'lib/build/files/composite.rb', line 60
def roots
@roots ||= @files.collect(&:roots).flatten.uniq
end
|
#to_paths ⇒ Object
88
89
90
|
# File 'lib/build/files/composite.rb', line 88
def to_paths
self.class.new(@files.collect(&:to_paths), roots: @roots)
end
|