Skip to content
instance method

ARGF#inplace_mode=

ARGF.inplace_mode = ext → ARGF

Sets the filename extension for in-place editing mode to the given String. The backup copy of each file being edited has this value appended to its filename.

For example:

$ ruby argf.rb file.txt

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

First, file.txt.bak is created as a backup copy of file.txt. Then, each line of file.txt has the first occurrence of “foo” replaced with “bar”.

See also #inplace_mode #inspect #gets #internal_encoding also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0