Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.19 KB | None | 0 0
  1. def truncate(text, length = 100, truncate_string = '...')
  2. if text
  3. l = length - truncate_string.chars.length
  4. (text.length > length ? text[0...l] + truncate_string : text).to_s
  5. end
  6. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement