Skip to content

Instantly share code, notes, and snippets.

@leepa leepa/gist:32293
Created Dec 5, 2008

Embed
What would you like to do?
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
You can’t perform that action at this time.