Class: Chitin::Directory
Instance Attribute Summary
Attributes inherited from FSObject
#path
Instance Method Summary
collapse
Methods inherited from FSObject
#initialize, #lstat, #to_s, #unknown_type?
Instance Method Details
114
115
116
117
|
# File 'lib/chitin/file.rb', line 114
def delete
File.rm_rf @path
end
|
95
96
97
98
|
# File 'lib/chitin/file.rb', line 95
def down
self.path = File.join path, '**'
self
end
|
#each(&block) ⇒ Object
106
107
108
|
# File 'lib/chitin/file.rb', line 106
def each(&block)
files.values.each &block
end
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/chitin/file.rb', line 76
def files
return @files if @files
files = Dir[File.join(path, '*')]
@files = files.inject({}) do |h, f|
f = f[2..-1] if f.start_with? './'
h[f] = if File.directory? f
D f
elsif File.file? f
F f
elsif File.symlink? f
S f
else
FSObject.new f, :unknown => true
end
h
end
end
|
119
120
121
|
# File 'lib/chitin/file.rb', line 119
def inspect
"#<Chitin::Directory #{path.inspect}>"
end
|
#level(n = 1) ⇒ Object
Get a specific level down
101
102
103
104
|
# File 'lib/chitin/file.rb', line 101
def level(n=1)
n.times { self.path = File.join path, '*' }
self
end
|
#symlink? ⇒ Boolean
123
124
125
|
# File 'lib/chitin/file.rb', line 123
def symlink?
false
end
|
110
111
112
|
# File 'lib/chitin/file.rb', line 110
def to_a
files.values
end
|