Class: TTY::Table::Operation::Truncation
- Inherits:
-
Object
- Object
- TTY::Table::Operation::Truncation
- Defined in:
- lib/tty/table/operation/truncation.rb
Overview
A class responsible for shortening text.
Instance Method Summary collapse
-
#call(row, options = {}) ⇒ Array[String]
Apply truncation to a row.
-
#truncate(string, width) ⇒ String
Shorten given string with traling character.
Instance Method Details
#call(row, options = {}) ⇒ Array[String]
Apply truncation to a row
18 19 20 21 22 23 24 25 |
# File 'lib/tty/table/operation/truncation.rb', line 18 def call(row, ={}) index = 0 row.map! do |field| width = .fetch(:column_widths, {})[index] || field.width index += 1 field.value = truncate(field.value, width) end end |