Class: Build::Files::Paths

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

Constant Summary

Constants inherited from List

List::NONE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from List

#+, #-, #==, coerce, #create, #delete, #exist?, #intersects?, #map, #rebase, #to_s, #touch, #with

Constructor Details

#initialize(list, roots = nil) ⇒ Paths

Returns a new instance of Paths.



26
27
28
29
# File 'lib/build/files/paths.rb', line 26

def initialize(list, roots = nil)
	@list = Array(list).freeze
	@roots = roots
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



31
32
33
# File 'lib/build/files/paths.rb', line 31

def list
  @list
end

Class Method Details

.directory(root, relative_paths) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/build/files/paths.rb', line 64

def self.directory(root, relative_paths)
	paths = relative_paths.collect do |path|
		Path.join(root, path)
	end
	
	self.new(paths, [root])
end

Instance Method Details

#countObject



38
39
40
# File 'lib/build/files/paths.rb', line 38

def count
	@list.count
end

#eachObject



42
43
44
45
46
# File 'lib/build/files/paths.rb', line 42

def each
	return to_enum(:each) unless block_given?
	
	@list.each{|path| yield path}
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/build/files/paths.rb', line 48

def eql?(other)
	self.class.eql?(other.class) and @list.eql?(other.list)
end

#hashObject



52
53
54
# File 'lib/build/files/paths.rb', line 52

def hash
	@list.hash
end

#inspectObject



60
61
62
# File 'lib/build/files/paths.rb', line 60

def inspect
	"<Paths #{@list.inspect}>"
end

#rootsObject

The list of roots for a given list of immutable files is also immutable, so we cache it for performance:



34
35
36
# File 'lib/build/files/paths.rb', line 34

def roots
	@roots ||= super
end

#to_pathsObject



56
57
58
# File 'lib/build/files/paths.rb', line 56

def to_paths
	self
end