Class: Build::Files::Directory

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

Constant Summary

Constants inherited from List

List::NONE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from List

#+, coerce, #intersects?, #map, #to_paths, #with

Constructor Details

#initialize(root) ⇒ Directory

Returns a new instance of Directory.



30
31
32
# File 'lib/build/files/directory.rb', line 30

def initialize(root)
	@root = root
end

Class Method Details

.join(*args) ⇒ Object



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

def self.join(*args)
	self.new(Path.join(*args))
end

Instance Method Details

#eachObject



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

def each
	return to_enum(:each) unless block_given?
	
	Dir.glob(@root + "**/*") do |path|
		yield Path.new(path, @root)
	end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/build/files/directory.rb', line 50

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

#hashObject



54
55
56
# File 'lib/build/files/directory.rb', line 54

def hash
	@root.hash
end

#include?(path) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
61
# File 'lib/build/files/directory.rb', line 58

def include?(path)
	# Would be true if path is a descendant of full_path.
	path.start_with?(@root)
end

#rebase(root) ⇒ Object



63
64
65
# File 'lib/build/files/directory.rb', line 63

def rebase(root)
	self.class.new(@root.rebase(root))
end

#rootObject



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

def root
	@root
end

#rootsObject



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

def roots
	[root]
end

#to_pathObject



71
72
73
# File 'lib/build/files/directory.rb', line 71

def to_path
	@root
end

#to_strObject



67
68
69
# File 'lib/build/files/directory.rb', line 67

def to_str
	@root.to_str
end