module Doing::Completion::StringUtils

Public Instance Methods

ltrunc(max) click to toggle source

Truncate string from left

@param max The maximum number of characters

# File lib/doing/completion/completion_string.rb, line 19
def ltrunc(max)
  if length > max
    sub(/^.*?(.{#{max - 3}})$/, '...\1')
  else
    self
  end
end
ltrunc!(max) click to toggle source
# File lib/doing/completion/completion_string.rb, line 27
def ltrunc!(max)
  replace ltrunc(max)
end
short_desc() click to toggle source

Get short description for command completion

@return [String] Short description

# File lib/doing/completion/completion_string.rb, line 10
def short_desc
  split(/[,.]/)[0].sub(/ \(.*?\)?$/, '').strip
end