Skip to content

Instantly share code, notes, and snippets.

@ryanwood
Created July 10, 2013 02:58
Show Gist options
  • Save ryanwood/5963144 to your computer and use it in GitHub Desktop.
Save ryanwood/5963144 to your computer and use it in GitHub Desktop.
Center ellipsis
def hollow(text, minimum_length = 4, edge_length = 3)
return text if text.length < minimum_length or text.length <= edge_length*2
edge = '.'*edge_length
mid_length = text.length - edge_length*2
text.gsub(/(#{edge}).{#{mid_length},}(#{edge})/, '\1...\2')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment