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
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_desc ⇒ String
Get short description for command completion
10 11 12 |
# File 'lib/doing/completion/completion_string.rb', line 10 def short_desc split(/[,.]/)[0].sub(/ \(.*?\)?$/, '').strip end |