Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Editlines

Extends core File class with File.editlines to edit lines in place. File.editlines works like File.foreach except that the return value of its associated block replaces each line in place.

Installation

$ gem install editlines

Usage

Given a file such as the following one:

$ cat myfile.txt
first line
second line
third line

Running this...

require 'editlines'

File.editlines('myfile.txt') do |line|
  line.capitalize
end

will replace each line of myfile.txt in place with the return value of the associated block. In this case, we capitalized the first letter of each line.

$ cat myfile.txt
First line
Second line
Third line

About

Extends core File class with File.editlines to edit lines of a file in place

Resources

License

Releases

No releases published

Packages

No packages published

Languages