inplace_mode=

ARGF.inplace_mode = ext â ARGF
Instance Public methods
Sets the filename extension for inplace 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.lines 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.

doc_ruby_on_rails
2015-03-30 11:42:37
Comments
Leave a Comment

Please login to continue.