Archived
1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
cli-old/lib/helpers.rb
2017-07-27 23:18:28 +00:00

17 lines
477 B
Ruby

# frozen_string_literal: true
module Helpers
refine String do
def etc(max_length, etc: '...')
return self if length <= max_length
return '' unless max_length.positive?
orig_length = max_length - etc.length
return etc[0...max_length] if orig_length <= 0
"#{self[0...orig_length]}#{etc}"
end
def ljustetc(required_length, padstr: ' ', etc: '...')
ljust(required_length, padstr).etc(required_length, etc: etc)
end
end
end