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, #copy, #create, #delete, #empty?, #exist?, #intersects?, #map, #to_paths, #touch, #with

Constructor Details

#initialize(root) ⇒ Directory

Returns a new instance of Directory.



15
16
17
# File 'lib/build/files/directory.rb', line 15

def initialize(root)
	@root = root
end

Class Method Details

.join(*args) ⇒ Object



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

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

Instance Method Details

#eachObject



27
28
29
30
31
32
33
34
# File 'lib/build/files/directory.rb', line 27

def each
	return to_enum(:each) unless block_given?
	
	# We match both normal files with * and dotfiles with .?*
	Dir.glob(@root + "**/{*,.?*}") do |path|
		yield Path.new(path, @root)
	end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/build/files/directory.rb', line 36

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

#hashObject



40
41
42
# File 'lib/build/files/directory.rb', line 40

def hash
	@root.hash
end

#include?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#rebase(root) ⇒ Object



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

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

#rootObject



19
20
21
# File 'lib/build/files/directory.rb', line 19

def root
	@root
end

#rootsObject



23
24
25
# File 'lib/build/files/directory.rb', line 23

def roots
	[root]
end

#to_pathObject



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

def to_path
	@root
end

#to_sObject



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

def to_s
	to_str
end

#to_strObject

Convert a Directory into a String, can be used as an argument to a command.



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

def to_str
	@root.to_str
end