Project

editlines

0.0
No commit activity in last 3 years
No release in over 3 years
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.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.6
~> 10.0
~> 3.0
 Project Readme

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