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



19
20
21
22
23
24
25
# 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) ⇒ Object



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

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

#short_descString

Get short description for command completion

Returns:

  • (String)

    Short description



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

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