class Text

Public Class Methods

replace_in_file(filename,search,replace) click to toggle source
# File lib/text.rb, line 6
def self.replace_in_file(filename,search,replace)
  text1 = IO.read(filename)
  text2 = text1.gsub(search) { |str| str=replace }
  unless text1==text2
    File.open(filename,"w") { |f| f.puts text2 }
    return true
  end
  false
end
replace_in_glob(glob,search,replace) click to toggle source
# File lib/text.rb, line 2
def self.replace_in_glob(glob,search,replace)
   Dir.glob(glob).each{ |f| replace_in_file(f,search,replace) }
 end