Class: Build::Files::Paths

Inherits:
List
  • Object
show all
Defined in:
lib/build/files/list.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, #intersects?, #map, #rebase, #with

Constructor Details

#initialize(list, roots = nil) ⇒ Paths

Returns a new instance of Paths.



81
82
83
84
# File 'lib/build/files/list.rb', line 81

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

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



86
87
88
# File 'lib/build/files/list.rb', line 86

def list
  @list
end

Class Method Details

.directory(root, relative_paths) ⇒ Object



119
120
121
122
123
124
125
# File 'lib/build/files/list.rb', line 119

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



93
94
95
# File 'lib/build/files/list.rb', line 93

def count
	@list.count
end

#eachObject



97
98
99
100
101
# File 'lib/build/files/list.rb', line 97

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/build/files/list.rb', line 103

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

#hashObject



107
108
109
# File 'lib/build/files/list.rb', line 107

def hash
	@list.hash
end

#inspectObject



115
116
117
# File 'lib/build/files/list.rb', line 115

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:



89
90
91
# File 'lib/build/files/list.rb', line 89

def roots
	@roots ||= super
end

#to_pathsObject



111
112
113
# File 'lib/build/files/list.rb', line 111

def to_paths
	self
end