lib/ld/file.rb in ld-0.1.9 vs lib/ld/file.rb in ld-0.1.10
- old
+ new
@@ -28,10 +28,44 @@
end
arr.sort!{|a,b| b.type-a.type}
arr
end
+ def search_files regexp
+ arr = []
+ iter_search_files regexp, arr
+ arr
+ end
+
+ def search_dirs
+ arr = []
+ iter_search_dir arr
+ arr
+ end
+
+ def iter_search_dir arr
+ children.each do |f|
+ if f.type == 1
+ arr << f
+ f.iter_search_dir arr
+ end
+ end
+ self
+ end
+
+ def iter_search_files regexp, arr
+ children.each do |f|
+ if f.type == 1
+ f.iter_search_files regexp, arr
+ end
+ if f.name.match(regexp)
+ arr << f
+ end
+ end
+ self
+ end
+
def father
arr = @path.split('/')
arr.pop
Ld::File.new(arr.join('/'))
end
@@ -50,43 +84,9 @@
File.open(@path).read
end
def readlines
File.open(@path).readlines
- end
-
- def where regexp
- arr = []
- iter_search regexp, arr
- arr
- end
-
- def search regexp
- arr = []
- iter_search regexp, arr
- arr
- end
-
- def iter_search regexp, arr
- children.each do |f|
- if f.type == 1
- f.iter_search regexp, arr
- end
- if f.name.match(regexp)
- arr << f
- end
- end
- self
- end
-
- def iter arr
- children.each do |f|
- if f.type == 1
- f.iter arr
- end
- arr << f
- end
- self
end
def size
File.size path
end