module GitTopic::Formatter::Helper
Public Instance Methods
truncate(str, truncate_at: 20)
click to toggle source
# File lib/git_topic/formatter/helper.rb, line 7 def truncate(str, truncate_at: 20) omission = '...' length_with_room_for_omission = truncate_at - omission.length if str.length > truncate_at "#{str[0, length_with_room_for_omission]}#{omission}" else str end end