R
Ruby Newbee
Hi,
I just wrote a small script to find the files in current directory and
its child directories which include the word "ruby".
But it can't work, please help point out my error, thanks.
def myfind(path=".")
Dir.foreach(path) do |f|
if File.file? f
open(f) do |c|
puts "#{path}/#{f}" if c.read.scan(/ruby/)
end
elsif File.directory? f
newpath = File.join path,f
myfind(newpath)
end
end
end
myfind
I just wrote a small script to find the files in current directory and
its child directories which include the word "ruby".
But it can't work, please help point out my error, thanks.
def myfind(path=".")
Dir.foreach(path) do |f|
if File.file? f
open(f) do |c|
puts "#{path}/#{f}" if c.read.scan(/ruby/)
end
elsif File.directory? f
newpath = File.join path,f
myfind(newpath)
end
end
end
myfind