
linebreak.rb v1.0

It is the Ruby program to split long lines in text to shorter.

When run without parameters, linebreak.rb outputs its version and usage format.

(c)2026, Vartiklis, Jonas Skendelis. The linebreak.rb is distributed 
under MIT License (see license.txt file) allowing to use, copy, modify, 
merge, publish, distribute, sublicense, and/or sell its copies. 
Its copyright notice and license text shall be included in all copies 
or substantial portions of this Software.


Usage
_____

As Ruby is interpreted language the linebreak.rb must be run only using 
ruby interpreter program. The program name and all needed parameters must
be provided to that interpreter.

The parameters must be in strict order. First two are input and output files.
After them parameters MIN and MAX to control line lengths could be
(as well as in uppercase or lowercase and their order is not important). 
They are not mandatory and if are ommited, the default values 68 and 80 are used.
All other usages cause error message.

So format of parameters is:

ruby linebreak.rb initial_file output_file [MIN=nn] [MAX=mm]
or
ruby linebreak.rb initial_file output_file [MIN:nn] [MAX:mm] 
where nn and mm  integer numbers and MIN <= MAX

Examples:
ruby linebreak.rb initial_text.txt splitted_text.txt -MIN=70 -MAX=102
ruby linebreak initial_text.rb.txt splitted_text.txt -Max:90 -min:72
ruby linebreak initial_text.rb.txt splitted_text.txt -max:102

As mentioned, the program without parameters outputs its version and usage format.
But it accepts parameters HELP and VERSION.
They must start with '-' or '--'.
HELP has alternative format '?' (without starting '-')
If HELP or VERSION is used then other parameters are not allowed
(that is, it can be only HELP or VERSION).
HELP outputs program version and usage format.
VERSION outputs only program version.

So their usage formats are:

ruby linebreak.rb ?
ruby linebreak.rb -help
ruby linebreak.rb --help
ruby linebreak.rb -version
ruby linebreak.rb --version


Detailed description
____________________

Two parameters are used to control splitting: one to define the minimal 
length and another to define maximal length. A line part till minimal 
length is kept as is and then further the space is searching to make 
the split in that position. If space was not find then break happens 
at maximal length position.

The command below reads a text from file initial_text.txt and breaks 
line leaving at least of 70 symbols but not longer as 102 symbols. The 
break will be done at first space after 70th position. The result will 
be to written into file splitted_text.txt

ruby linebreak.rb initial_text.txt splitted_text.txt MIN=70 MAX=102 


Other versions
______________

linebreak is implemented using other languages, too:
Perl, AWK, PXP Plus, C and C++
All these implementations could be downliaded from
http://www.vartiklis.lt/lthfree/lthfree.htm

At the moment there are no plans to update linebreak.rb for Ruby
with new features or make more flexible its usage.
You can do that yourself!
