Class: ReplaceDocument
- Inherits:
-
Object
- Object
- ReplaceDocument
- Defined in:
- lib/replace_it.rb
Instance Attribute Summary collapse
-
#original_file ⇒ Object
Returns the value of attribute original_file.
-
#temp_file ⇒ Object
Returns the value of attribute temp_file.
Instance Method Summary collapse
- #document_replace(string, new_string) ⇒ Object
-
#initialize(original_file, temp_file) ⇒ ReplaceDocument
constructor
A new instance of ReplaceDocument.
Constructor Details
#initialize(original_file, temp_file) ⇒ ReplaceDocument
Returns a new instance of ReplaceDocument.
6 7 8 9 |
# File 'lib/replace_it.rb', line 6 def initialize(original_file, temp_file) @original_file = original_file @temp_file = temp_file end |
Instance Attribute Details
#original_file ⇒ Object
Returns the value of attribute original_file.
4 5 6 |
# File 'lib/replace_it.rb', line 4 def original_file @original_file end |
#temp_file ⇒ Object
Returns the value of attribute temp_file.
4 5 6 |
# File 'lib/replace_it.rb', line 4 def temp_file @temp_file end |
Instance Method Details
#document_replace(string, new_string) ⇒ Object
11 12 13 14 15 |
# File 'lib/replace_it.rb', line 11 def document_replace(string, new_string) File.open(@temp_file, 'w') do |file| file.puts File.read(@original_file).gsub(/#{string}/, new_string) end end |