method

inplace_mode=

Importance_1
Ruby latest stable (v2_5_5) - 0 notes - Class: ARGF
inplace_mode=(p1) public

Sets the filename extension for in-place editing mode to the given String. Each file being edited has this value appended to its filename. The modified file is saved under this new name.

For example:

$ ruby argf.rb file.txt

ARGF.inplace_mode = '.bak'
ARGF.each_line do |line|
  print line.sub("foo","bar")
end

Each line of file.txt has the first occurrence of “foo” replaced with “bar”, then the new line is written out to file.txt.bak.

Show source
Register or log in to add new notes.