Class: Build::Files::Glob
- Inherits:
-
List
- Object
- List
- Build::Files::Glob
show all
- Defined in:
- lib/build/files/glob.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_paths, #to_s, #touch, #with
Constructor Details
#initialize(root, pattern) ⇒ Glob
Returns a new instance of Glob.
32
33
34
35
|
# File 'lib/build/files/glob.rb', line 32
def initialize(root, pattern)
@root = root
@pattern = pattern
end
|
Instance Attribute Details
#pattern ⇒ Object
Returns the value of attribute pattern.
38
39
40
|
# File 'lib/build/files/glob.rb', line 38
def pattern
@pattern
end
|
#root ⇒ Object
Returns the value of attribute root.
37
38
39
|
# File 'lib/build/files/glob.rb', line 37
def root
@root
end
|
Instance Method Details
#each(&block) ⇒ Object
Enumerate all paths matching the pattern.
49
50
51
52
53
54
55
|
# File 'lib/build/files/glob.rb', line 49
def each(&block)
return to_enum(:each) unless block_given?
Dir.glob(full_pattern) do |path|
yield Path.new(path, @root)
end
end
|
#eql?(other) ⇒ Boolean
57
58
59
|
# File 'lib/build/files/glob.rb', line 57
def eql?(other)
self.class.eql?(other.class) and @root.eql?(other.root) and @pattern.eql?(other.pattern)
end
|
#full_pattern ⇒ Object
44
45
46
|
# File 'lib/build/files/glob.rb', line 44
def full_pattern
Path.join(@root, @pattern)
end
|
#hash ⇒ Object
61
62
63
|
# File 'lib/build/files/glob.rb', line 61
def hash
[@root, @pattern].hash
end
|
#include?(path) ⇒ Boolean
65
66
67
|
# File 'lib/build/files/glob.rb', line 65
def include?(path)
File.fnmatch(full_pattern, path)
end
|
#inspect ⇒ Object
73
74
75
|
# File 'lib/build/files/glob.rb', line 73
def inspect
"<Glob #{full_pattern.inspect}>"
end
|
#rebase(root) ⇒ Object
69
70
71
|
# File 'lib/build/files/glob.rb', line 69
def rebase(root)
self.class.new(root, @pattern)
end
|
#roots ⇒ Object
40
41
42
|
# File 'lib/build/files/glob.rb', line 40
def roots
[@root]
end
|