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



8
9
10
11
12
13
14
# File 'lib/doing/completion/completion_string.rb', line 8

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

#ltrunc!(max) ⇒ Object



16
17
18
# File 'lib/doing/completion/completion_string.rb', line 16

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

#short_descObject



4
5
6
# File 'lib/doing/completion/completion_string.rb', line 4

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