Text::Format for Ruby is copyright 2002 - 2005 by Austin Ziegler. It is
available under Ruby’s licence, the Perl Artistic licence, or the GNU
GPL version 2 (or at your option, any later version). As a special
exception, for use with official Rails (provided by the rubyonrails.org
development team) and any project created with official Rails, the
following alternative MIT-style licence may be used:
Text::Format Licence for Rails and Rails Applications
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the
following conditions:
- The names of its contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
| Classes |
| SplitWord |
Words forcibly split by Text::Format will be stored as split words. This
class represents a word forcibly split.
|
| Public Attributes |
| abbreviations |
Defines the current abbreviations as an array. This is only used if
extra_space is turned on.
|
| body_indent |
The number of spaces to indent all lines after the first line of a
paragraph.
|
| columns |
The total width of the format area. The margins, indentation, and text are
formatted into this space.
|
| extra_space |
Indicates whether sentence terminators should be followed by a single space
(false), or two spaces (true).
|
| first_indent |
The number of spaces to indent the first line of a paragraph.
|
| format_style |
Specifies the format style. Allowable values are:
|
| hard_margins |
Normally, words larger than the format area will be placed on a line by
themselves. Setting this to true will force words larger than the
format area to be split into one or more "words" each at most the
size of the format area. The first line and the original word will be
placed into #split_words. Note that this will cause the output to
look similar to a #format_style of JUSTIFY. (Lines will be filled as
much as possible.)
|
| hyphenator |
The object responsible for hyphenating. It must respond to
#hyphenate_to(word, size) or #hyphenate_to(word, size, formatter) and
return an array of the word split into two parts; if there is a hyphenation
mark to be applied, responsibility belongs to the hyphenator object. The
size is the MAXIMUM size permitted, including any hyphenation marks. If the
#hyphenate_to method has an arity of 3, the formatter will be provided to
the method. This allows the hyphenator to make decisions about the
hyphenation based on the formatting rules.
|
| left_margin |
The number of spaces used for the left margin.
|
| nobreak |
Indicates whether or not the non-breaking space feature should be used.
|
| nobreak_regex |
A hash which holds the regular expressions on which spaces should not be
broken. The hash is set up such that the key is the first word and the
value is the second word.
|
| right_margin |
The number of spaces used for the right margin.
|
| split_rules |
Specifies the split mode; used only when #hard_margins is set to
true. Allowable values are:
|
| split_words |
An array of words split during formatting if #hard_margins is set to
true.
|
| tabstop |
Indicates the number of spaces that a single tab represents.
|
| tag_paragraph |
Indicates whether the formatting of paragraphs should be done with tagged
paragraphs. Useful only with #tag_text.
|
| tag_text |
The array of text to be placed before each paragraph when
#tag_paragraph is true. When #format() is
called, only the first element of the array is used. When
#paragraphs is called, then each entry in the array will be used
once, with corresponding paragraphs. If the tag elements are exhausted
before the text is exhausted, then the remaining paragraphs will not be
tagged. Regardless of indentation settings, a blank line will be inserted
between all paragraphs when #tag_paragraph is true.
|
| text |
The text to be manipulated. Note that value is optional, but if the
formatting functions are called without values, this text is what will be
formatted.
|
| Public Methods |
| == |
Compares two Text::Format objects. All settings of the objects are compared
except #hyphenator. Generated results (e.g., #split_words) are not
compared, either.
|
| body_indent= |
The number of spaces to indent all lines after the first line of a
paragraph. The value provided is silently converted to a positive integer
value.
|
| center |
Centers the text, preserving empty lines and tabs.
|
| columns= |
The total width of the format area. The margins, indentation, and text are
formatted into this space. The value provided is silently converted to a
positive integer.
|
| expand |
Replaces all tab characters in the text with #tabstop spaces.
|
| first_indent= |
The number of spaces to indent the first line of a paragraph. The value
provided is silently converted to a positive integer value.
|
| format |
Formats text into a nice paragraph format. The text is separated into words
and then reassembled a word at a time using the settings of this Format
object. If a word is larger than the number of columns available for
formatting, then that word will appear on the line by itself.
|
| format_style= |
Specifies the format style. Allowable values are:
|
| hyphenate_to |
The default implementation of #hyphenate_to implements SPLIT_CONTINUATION.
|
| hyphenator= |
The object responsible for hyphenating. It must respond to
#hyphenate_to(word, size) and return an array of the word hyphenated into
two parts. The size is the MAXIMUM size permitted, including any
hyphenation marks.
|
| justify? |
Indicates that the format style is full justification.
|
| left_align? |
Indicates that the format style is left alignment.
|
| left_margin= |
The number of spaces used for the left margin. The value provided is
silently converted to a positive integer value.
|
| new |
This constructor takes advantage of a technique for Ruby object
construction introduced by Andy Hunt and Dave Thomas (see reference), where
optional values are set using commands in a block.
|
| paragraphs |
Considers each element of text (provided or internal) as a paragraph. If
#first_indent is the same as #body_indent, then
paragraphs will be separated by a single empty line in the result;
otherwise, the paragraphs will follow immediately after each other. Uses
#format to do the heavy lifting.
|
| right_align? |
Indicates that the format style is right alignment.
|
| right_fill? |
Indicates that the format style is right fill.
|
| right_margin= |
The number of spaces used for the right margin. The value provided is
silently converted to a positive integer value.
|
| split_rules= |
Specifies the split mode; used only when #hard_margins is set to
true. Allowable values are:
|
| tabstop= |
Indicates the number of spaces that a single tab represents.
|
| unexpand |
Replaces all occurrences of #tabstop consecutive spaces with a tab
character.
|
<code/>and<pre/>for code samples.