truncate & truncateFromCenter method with test

Hi,

I based the `truncateFromCenter` method from your gist and it works perfect :)