Sha256: f1a476822a53feb8a78db1b85e19bf2ebc694d87f5f11888ff98c1d1a899affe

Contents?: true

Size: 459 Bytes

Versions: 1

Compression:

Stored size: 459 Bytes

Contents

require 'hammer_cli/output/utils'

module TablePrint
  class FixedWidthFormatter
    def format(value)
      value = value.to_s
      padding = width - HammerCLI::Output::Utils.real_length(value)
      if padding >= 0
        value += (" " * padding)
      else
        value, real_length = HammerCLI::Output::Utils.real_truncate(value, width-3)
        value += '...'
        value += ' ' if real_length < (width - 3)
      end
      value
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hammer_cli-0.9.0 lib/hammer_cli/table_print/formatter.rb