Class: TTY::Table::Operation::Wrapped Private
- Inherits:
-
Object
- Object
- TTY::Table::Operation::Wrapped
- Defined in:
- lib/tty/table/operation/wrapped.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A class responsible for wrapping text.
Instance Attribute Summary collapse
- #padding ⇒ Object readonly private
- #widths ⇒ Object readonly private
Instance Method Summary collapse
-
#call(field, row, col) ⇒ Array[String]
Apply wrapping to a field.
-
#initialize(widths, padding) ⇒ Wrapped
constructor
Initialize a Wrapped.
-
#wrap(string, width) ⇒ String
Wrap a long string according to the width.
Constructor Details
#initialize(widths, padding) ⇒ Wrapped
Initialize a Wrapped
18 19 20 21 |
# File 'lib/tty/table/operation/wrapped.rb', line 18 def initialize(widths, padding) @widths = widths @padding = padding.padding end |
Instance Attribute Details
#padding ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/tty/table/operation/wrapped.rb', line 13 def padding @padding end |
#widths ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/tty/table/operation/wrapped.rb', line 11 def widths @widths end |
Instance Method Details
#call(field, row, col) ⇒ Array[String]
Apply wrapping to a field
37 38 39 40 |
# File 'lib/tty/table/operation/wrapped.rb', line 37 def call(field, row, col) width = widths[col] || field.width field.value = wrap(field.value, width) end |