Class: Incr::Service::FileHelper
- Inherits:
-
Object
- Object
- Incr::Service::FileHelper
- Defined in:
- lib/incr/service/file_helper.rb
Class Method Summary collapse
Class Method Details
.replace(filename, pattern, replacement_text) ⇒ Object
4 5 6 7 8 |
# File 'lib/incr/service/file_helper.rb', line 4 def self.replace(filename, pattern, replacement_text) old_content = File.read(filename) new_content = old_content.sub(pattern, replacement_text) File.open(filename, 'w') { |file| file << new_content } end |