Sha256: 5fcd2c583722fc46bb7e56ad3b7933b36eb40023958380b2b68652cf23809d32

Contents?: true

Size: 886 Bytes

Versions: 5

Compression:

Stored size: 886 Bytes

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
          Verse.truncate(field.content, width)
        end
      end # Truncation
    end # Operation
  end # Table
end # TTY

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tty-table-0.6.0 lib/tty/table/operation/truncation.rb
tty-table-0.5.0 lib/tty/table/operation/truncation.rb
tty-table-0.4.0 lib/tty/table/operation/truncation.rb
tty-table-0.3.0 lib/tty/table/operation/truncation.rb
tty-table-0.2.0 lib/tty/table/operation/truncation.rb