<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: plain code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 23 Jul 2008 21:47:37 GMT</pubDate>
    <description>DZone Snippets: plain code</description>
    <item>
      <title>Elegant way of shorten a text string</title>
      <link>http://snippets.dzone.com/posts/show/4578</link>
      <description>this method shortens a plain text string down to complete words contained in given scope (count)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def shorten (string, count = 30)&lt;br /&gt;	if string.length &gt;= count &lt;br /&gt;		shortened = string[0, count]&lt;br /&gt;		splitted = shortened.split(/\s/)&lt;br /&gt;		words = splitted.length&lt;br /&gt;		splitted[0, words-1].join(" ") + ' ...'&lt;br /&gt;	else &lt;br /&gt;		string&lt;br /&gt;	end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 27 Sep 2007 11:47:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4578</guid>
      <author>labuschin (Martin Labuschin)</author>
    </item>
  </channel>
</rss>
