Hello,
I defined an iterator and tried using it and got a no block given
error. I dont understand why I got this error because I did define a
block. The yield statement is in the replace_text function and the
iterator is called in the remove_destroy function.
Thank you,
Brian Takita
def replace_text(dir_name = ‘.’)
#raise “No Block” unless block_given?
d = Dir.new(dir_name)
d.each{|x|
if x == '.' || x == '..'
next
end
if FileTest.directory?(x)
puts dir_name + '--' + x
Dir.chdir(x)
replace_text()
Dir.chdir('..')
else
if x =~ /(\.php)/
puts dir_name + '->' + x
f = File.new(x)
content = ''
f.each_line { |line|
yield line
content +=
line
}
f.close
f = File.new(dir_name +
‘/’ +x, ‘w+’)
f.write(content)
f.close
end
end
}
d.close
end
def remove_destroy()
replace_text { |line|
if line =~ /.->destroy().\n/
line = ""
end
}
end
remove_destroy()