Class: TTY::Text
- Inherits:
-
Object
- Object
- TTY::Text
- Defined in:
- lib/tty/text.rb,
lib/tty/text/distance.rb,
lib/tty/text/wrapping.rb,
lib/tty/text/truncation.rb
Overview
A class responsible for text manipulations
Defined Under Namespace
Classes: Distance, Truncation, Wrapping
Constant Summary collapse
- SPACE =
" ".freeze
- NEWLINE =
"\n".freeze
- DEFAULT_WIDTH =
80.freeze
Class Method Summary collapse
-
.distance(first, second, *args) ⇒ Object
Calculate the distance between strings.
-
.truncate(text, *args) ⇒ Object
Truncate a text at a given length (defaults to 30).
-
.wrap(text, *args) ⇒ Object
Wrap a text into lines no longer than provided length.
Instance Method Summary collapse
-
#split_mode ⇒ Object
Specifies the split mode for words.
Class Method Details
.distance(first, second, *args) ⇒ Object
Calculate the distance between strings
30 31 32 |
# File 'lib/tty/text.rb', line 30 def self.distance(first, second, *args) Distance.new(first, second, *args).distance end |
.truncate(text, value) ⇒ Object .truncate(text, value, options) ⇒ Object
Truncate a text at a given length (defaults to 30)
96 97 98 |
# File 'lib/tty/text.rb', line 96 def self.truncate(text, *args) Truncation.new(text, *args).truncate end |
.wrap(text, value) ⇒ Object .wrap(text, value, options) ⇒ Object
Wrap a text into lines no longer than provided length
62 63 64 |
# File 'lib/tty/text.rb', line 62 def self.wrap(text, *args) Wrapping.new(text, *args).wrap end |
Instance Method Details
#split_mode ⇒ Object
Specifies the split mode for words
15 16 |
# File 'lib/tty/text.rb', line 15 def split_mode end |