Sha256: f3eb3c168441f4dfd6a6b038f5e724766efa75e05935b16b271f5d0b57bd7b7a

Contents?: true

Size: 428 Bytes

Versions: 3

Compression:

Stored size: 428 Bytes

Contents

# frozen_string_literal: true

module GitTopic
  module Formatter
    # Helper class for Formatter classes
    module Helper
      def truncate(str, truncate_at: 20)
        omission = '...'
        length_with_room_for_omission = truncate_at - omission.length
        if str.length > truncate_at
          "#{str[0, length_with_room_for_omission]}#{omission}"
        else
          str
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_topic-0.4.0 lib/git_topic/formatter/helper.rb
git_topic-0.3.3 lib/git_topic/formatter/helper.rb
git_topic-0.3.0 lib/git_topic/formatter/helper.rb