Sha256: fa390871a68258cb2aafe8a70758257944d2582726a52990779f72f41c4af59b
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
# encoding: utf-8 module TTY class Table module Operation # A class responsible for shortening text. # # @api private class Truncation attr_reader :widths # Initialize a Truncation # # @api public def initialize(widths) @widths = widths end # Apply truncation to a field # # @param [TTY::Table::Field] field # the table field # # @param [Integer] row # the field row index # # @param [Integer] col # the field column index # # @return [TTY::Table::Field] # # @api public def call(field, row, col) width = widths[col] || field.width field.value = truncate(field.value, width) end # Shorten given string with traling character. # # @param [String] string # the string to truncate # @param [Integer] width # the maximum width # # @return [String] # # @api public def truncate(string, width) TTY::Text.truncate(string, width) end end # Truncation end # Operation end # Table end # TTY
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tty-0.1.2 | lib/tty/table/operation/truncation.rb |
tty-0.1.1 | lib/tty/table/operation/truncation.rb |
tty-0.1.0 | lib/tty/table/operation/truncation.rb |