module TestProf::StringTruncate
Extend String with truncate
method
Public Instance Methods
truncate(limit = 30)
click to toggle source
Truncate to the specified limit by replacing middle part with dots
# File lib/test_prof/ext/string_truncate.rb, line 9 def truncate(limit = 30) return self unless size > limit head = ((limit - 3) / 2) tail = head + 3 - limit "#{self[0..(head - 1)]}...#{self[tail..-1]}" end