Module: Doing::Completion::StringUtils
- Included in:
- String
- Defined in:
- lib/doing/completion/completion_string.rb
Instance Method Summary collapse
-
#ltrunc(max) ⇒ Object
Truncate string from left.
- #ltrunc!(max) ⇒ Object
-
#short_desc ⇒ String
Get short description for command completion.
Instance Method Details
#ltrunc(max) ⇒ Object
Truncate string from left
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_desc ⇒ String
Get short description for command completion
11 12 13 |
# File 'lib/doing/completion/completion_string.rb', line 11 def short_desc split(/[,.]/)[0].sub(/ \(.*?\)?$/, '').strip end |