Class: TTY::Table::Operation::Truncation Private
- Inherits:
-
Object
- Object
- TTY::Table::Operation::Truncation
- Defined in:
- lib/tty/table/operation/truncation.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 shortening text.
Instance Attribute Summary collapse
- #widths ⇒ Object readonly private
Instance Method Summary collapse
-
#call(field, row, col) ⇒ TTY::Table::Field
Apply truncation to a field.
-
#initialize(widths) ⇒ Truncation
constructor
Initialize a Truncation.
Constructor Details
#initialize(widths) ⇒ Truncation
Initialize a Truncation
18 19 20 |
# File 'lib/tty/table/operation/truncation.rb', line 18 def initialize(widths) @widths = widths end |
Instance Attribute Details
#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.
13 14 15 |
# File 'lib/tty/table/operation/truncation.rb', line 13 def widths @widths end |
Instance Method Details
#call(field, row, col) ⇒ TTY::Table::Field
Apply truncation to a field
36 37 38 39 |
# File 'lib/tty/table/operation/truncation.rb', line 36 def call(field, row, col) column_width = widths[col] || field.width Strings.truncate(field.content, column_width) end |