<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vidul Nikolaev Petrov &#187; RoR</title>
	<atom:link href="http://www.vidul.com/category/ror/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vidul.com</link>
	<description>my web space</description>
	<lastBuildDate>Thu, 09 Sep 2010 22:51:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting Core Objects&#8217; Methods in RoR</title>
		<link>http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/</link>
		<comments>http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 13:14:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[RoR]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[mkdir -p RAILS_ROOT/vendor/plugins/core_methods
mkdir -p RAILS_ROOT/vendor/plugins/core_methods/init.rb
The content of init.rb:

module Rails
&#160;
  empty_and_nil = %q&#123;def empty_and_nil; self.empty?? nil : self end&#125;
&#160;
  Array.send :class_eval, empty_and_nil
  Hash.send  :class_eval, empty_and_nil
&#160;
end

The namespace Rails isn’t necessary, it’s a cosmetic feature.





		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this on Reddit
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share this on [...]]]></description>
			<content:encoded><![CDATA[<p><em>mkdir -p RAILS_ROOT/vendor/plugins/core_methods</em></p>
<p><em>mkdir -p RAILS_ROOT/vendor/plugins/core_methods/init.rb</em><em></p>
<p>The content of init.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> Rails
&nbsp;
  empty_and_nil = <span style="color:#006600; font-weight:bold;">%</span>q<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#9966CC; font-weight:bold;">def</span> empty_and_nil; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">empty</span>?? <span style="color:#0000FF; font-weight:bold;">nil</span> : <span style="color:#0000FF; font-weight:bold;">self</span> <span style="color:#9966CC; font-weight:bold;">end</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">Array</span>.<span style="color:#9900CC;">send</span> <span style="color:#ff3333; font-weight:bold;">:class_eval</span>, empty_and_nil
  <span style="color:#CC00FF; font-weight:bold;">Hash</span>.<span style="color:#9900CC;">send</span>  <span style="color:#ff3333; font-weight:bold;">:class_eval</span>, empty_and_nil
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The namespace Rails isn’t necessary, it’s a cosmetic feature.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/&amp;Title=Setting+Core+Objects%27+Methods+in+RoR" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/&amp;title=Setting+Core+Objects%27+Methods+in+RoR" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/&amp;title=Setting+Core+Objects%27+Methods+in+RoR" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/&amp;title=Setting+Core+Objects%27+Methods+in+RoR" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/&amp;title=Setting+Core+Objects%27+Methods+in+RoR" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Setting+Core+Objects%27+Methods+in+RoR+-+http://b2l.me/bxgzj+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/&amp;h=Setting+Core+Objects%27+Methods+in+RoR" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/08/09/setting-core-objects-methods-in-ror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>to truncate or not?</title>
		<link>http://www.vidul.com/2008/07/10/to-truncate-or-not/</link>
		<comments>http://www.vidul.com/2008/07/10/to-truncate-or-not/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 15:44:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[RoR]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
# RoR source code:
# File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 34
def truncate&#40;text, length = 30, truncate_string = &#34;...&#34;&#41;
  if text.nil? then return end
  l = length - truncate_string.chars.length
  text.chars.length &#62; length ? text.chars&#91;0...l&#93; + truncate_string : text
end
&#160;
# My point of view:
def truncate&#40;text, _length = 30, truncate_string = &#34;...&#34;&#41;
  text&#91;0..&#40;_length-1&#41;&#93; + truncate_string
end






		
			Share this on Blinklist
		
		
			Share [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;"><span style="color:#008000; font-style:italic;"># RoR source code:</span>
<span style="color:#008000; font-style:italic;"># File vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb, line 34</span>
<span style="color:#9966CC; font-weight:bold;">def</span> truncate<span style="color:#006600; font-weight:bold;">&#40;</span>text, length = <span style="color:#006666;">30</span>, truncate_string = <span style="color:#996600;">&quot;...&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> text.<span style="color:#0000FF; font-weight:bold;">nil</span>? <span style="color:#9966CC; font-weight:bold;">then</span> <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#9966CC; font-weight:bold;">end</span>
  l = length <span style="color:#006600; font-weight:bold;">-</span> truncate_string.<span style="color:#9900CC;">chars</span>.<span style="color:#9900CC;">length</span>
  text.<span style="color:#9900CC;">chars</span>.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">&gt;</span> length ? text.<span style="color:#9900CC;">chars</span><span style="color:#006600; font-weight:bold;">&#91;</span>0...<span style="color:#9900CC;">l</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> truncate_string : text
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># My point of view:</span>
<span style="color:#9966CC; font-weight:bold;">def</span> truncate<span style="color:#006600; font-weight:bold;">&#40;</span>text, _length = <span style="color:#006666;">30</span>, truncate_string = <span style="color:#996600;">&quot;...&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  text<span style="color:#006600; font-weight:bold;">&#91;</span>0..<span style="color:#006600; font-weight:bold;">&#40;</span>_length<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> truncate_string
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2008/07/10/to-truncate-or-not/&amp;Title=to+truncate+or+not%3F" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2008/07/10/to-truncate-or-not/&amp;title=to+truncate+or+not%3F" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2008/07/10/to-truncate-or-not/&amp;title=to+truncate+or+not%3F" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2008/07/10/to-truncate-or-not/&amp;title=to+truncate+or+not%3F" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2008/07/10/to-truncate-or-not/&amp;title=to+truncate+or+not%3F" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2008/07/10/to-truncate-or-not/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=to+truncate+or+not%3F+-+http://b2l.me/bmgd4+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2008/07/10/to-truncate-or-not/&amp;h=to+truncate+or+not%3F" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2008/07/10/to-truncate-or-not/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>auto_link and highlight</title>
		<link>http://www.vidul.com/2007/11/01/auto_link-and-highlight/</link>
		<comments>http://www.vidul.com/2007/11/01/auto_link-and-highlight/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 03:29:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
auto_link&#40;text&#41;&#123;&#124;link&#124; hightlight&#40;link, phrase&#41;&#125;






		
			Share this on Blinklist
		
		
			Share this on del.icio.us
		
		
			Digg this!
		
		
			Share this on Reddit
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share this on Technorati
		
		
			Tweet This!
		
		
			Seed this on Newsvine
		





]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:arial,verdana,monospace;">auto_link<span style="color:#006600; font-weight:bold;">&#40;</span>text<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>link<span style="color:#006600; font-weight:bold;">|</span> hightlight<span style="color:#006600; font-weight:bold;">&#40;</span>link, phrase<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-blinklist">
			<a href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&amp;Url=http://www.vidul.com/2007/11/01/auto_link-and-highlight/&amp;Title=auto_link+and+highlight" rel="nofollow" title="Share this on Blinklist">Share this on Blinklist</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://www.vidul.com/2007/11/01/auto_link-and-highlight/&amp;title=auto_link+and+highlight" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.vidul.com/2007/11/01/auto_link-and-highlight/&amp;title=auto_link+and+highlight" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://www.vidul.com/2007/11/01/auto_link-and-highlight/&amp;title=auto_link+and+highlight" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.vidul.com/2007/11/01/auto_link-and-highlight/&amp;title=auto_link+and+highlight" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://www.vidul.com/2007/11/01/auto_link-and-highlight/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=auto_link+and+highlight+-+http://b2l.me/bmrx6+" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.vidul.com/2007/11/01/auto_link-and-highlight/&amp;h=auto_link+and+highlight" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

]]></content:encoded>
			<wfw:commentRss>http://www.vidul.com/2007/11/01/auto_link-and-highlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
