Skip to content

Instantly share code, notes, and snippets.

@leepa
Created December 5, 2008 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leepa/32293 to your computer and use it in GitHub Desktop.
Save leepa/32293 to your computer and use it in GitHub Desktop.
def truncate_description(length, end_string = ' ...')
words = description.split()
words = words[0..(length-1)].join(' ') + (words.length > length ? end_string : '')
words
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment