Sha256: 3b9c477d7828b0fe6c5155cf0a062f70f40f63bc623db0b733f48a14f1ee7516

Contents?: true

Size: 425 Bytes

Versions: 15

Compression:

Stored size: 425 Bytes

Contents

module Doing
  module Completion
    module StringUtils
      def short_desc
        split(/[,.]/)[0].sub(/ \(.*?\)?$/, '').strip
      end

      def ltrunc(max)
        if length > max
          sub(/^.*?(.{#{max - 3}})$/, '...\1')
        else
          self
        end
      end

      def ltrunc!(max)
        replace ltrunc(max)
      end
    end
  end
end

class ::String
  include Doing::Completion::StringUtils
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
doing-2.1.58 lib/doing/completion/completion_string.rb
doing-2.1.57 lib/doing/completion/completion_string.rb
doing-2.1.56 lib/doing/completion/completion_string.rb
doing-2.1.55 lib/doing/completion/completion_string.rb
doing-2.1.54 lib/doing/completion/completion_string.rb
doing-2.1.52 lib/doing/completion/completion_string.rb
doing-2.1.49 lib/doing/completion/completion_string.rb
doing-2.1.48 lib/doing/completion/completion_string.rb
doing-2.1.47 lib/doing/completion/completion_string.rb
doing-2.1.46 lib/doing/completion/completion_string.rb
doing-2.1.45 lib/doing/completion/completion_string.rb
doing-2.1.44 lib/doing/completion/completion_string.rb
doing-2.1.43 lib/doing/completion/completion_string.rb
doing-2.1.42 lib/doing/completion/completion_string.rb
doing-2.1.41 lib/doing/completion/completion_string.rb