Module: Doing::Completion::StringUtils

Included in:
String
Defined in:
lib/doing/completion/completion_string.rb

Instance Method Summary collapse

Instance Method Details

#ltrunc(max) ⇒ Object

Truncate string from left

Parameters:

  • max

    The maximum number of characters



20
21
22
23
24
25
26
# File 'lib/doing/completion/completion_string.rb', line 20

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

#ltrunc!(max) ⇒ Object



28
29
30
# File 'lib/doing/completion/completion_string.rb', line 28

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

#short_descString

Get short description for command completion

Returns:

  • (String)

    Short description



11
12
13
# File 'lib/doing/completion/completion_string.rb', line 11

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