<?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; data</title>
	<atom:link href="http://www.vidul.com/category/ruby/data/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vidul.com</link>
	<description>my web space</description>
	<lastBuildDate>Sat, 24 Sep 2011 06:11:47 +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>Ruby __DATA__ (embedded data)</title>
		<link>http://www.vidul.com/2008/08/22/ruby-__data__-embedded-data/</link>
		<comments>http://www.vidul.com/2008/08/22/ruby-__data__-embedded-data/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 17:04:00 +0000</pubDate>
		<dc:creator>Vidul</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[data]]></category>

		<guid isPermaLink="false">urn:uuid:{a.guid}</guid>
		<description><![CDATA[
module Kernel
  RE_THIS_DATA = lambda&#123; &#124;number&#124; /^__DATA#{number}__\n/ }
  RE_THE_DATA  = /^__DATA\d+__/
&#160;
  def __data__&#40;num=&#34;&#34;&#41;
    data = File.read&#40;$0&#41;.split&#40;RE_THIS_DATA.call&#40;num&#41;&#41;
    data&#91;1&#93;.split&#40;RE_THE_DATA&#41;&#91;0&#93; if data&#91;1&#93;
  end
end
&#160;
puts &#34;DATA&#34;
print __data__&#40;&#41;
&#160;
puts &#34;DATA1&#34;
print __data__&#40;1&#41;
&#160;
puts &#34;DATA2&#34;
print __data__&#40;2&#41;
&#160;
__END__
&#160;
__DATA__
data_1
data_2
data_3
&#160;
__DATA1__
data1_1
data1_2
data1_3
&#160;
data1_11
&#160;
__DATA2__
data2_1
data2_2
data2_3
&#160;
data2_31






		
			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 [...]]]></description>
			<content:encoded><![CDATA[
<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> <span style="color:#CC00FF; font-weight:bold;">Kernel</span>
  RE_THIS_DATA = <span style="color:#CC0066; font-weight:bold;">lambda</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>number<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#006600; font-weight:bold;">/</span>^__DATA<span style="color:#008000; font-style:italic;">#{number}__\n/ }</span>
  RE_THE_DATA  = <span style="color:#006600; font-weight:bold;">/</span>^__DATA\d<span style="color:#006600; font-weight:bold;">+</span>__<span style="color:#006600; font-weight:bold;">/</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> __data__<span style="color:#006600; font-weight:bold;">&#40;</span>num=<span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    data = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">read</span><span style="color:#006600; font-weight:bold;">&#40;</span>$<span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span>RE_THIS_DATA.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>num<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    data<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span>RE_THE_DATA<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">if</span> data<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;DATA&quot;</span>
<span style="color:#CC0066; font-weight:bold;">print</span> __data__<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;DATA1&quot;</span>
<span style="color:#CC0066; font-weight:bold;">print</span> __data__<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;DATA2&quot;</span>
<span style="color:#CC0066; font-weight:bold;">print</span> __data__<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
__END__
&nbsp;
__DATA__
data_1
data_2
data_3
&nbsp;
__DATA1__
data1_1
data1_2
data1_3
&nbsp;
data1_11
&nbsp;
__DATA2__
data2_1
data2_2
data2_3
&nbsp;
data2_31</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/08/22/ruby-__data__-embedded-data/&amp;Title=Ruby+__DATA__+%28embedded+data%29" 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/22/ruby-__data__-embedded-data/&amp;title=Ruby+__DATA__+%28embedded+data%29" 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/22/ruby-__data__-embedded-data/&amp;title=Ruby+__DATA__+%28embedded+data%29" 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/22/ruby-__data__-embedded-data/&amp;title=Ruby+__DATA__+%28embedded+data%29" 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/22/ruby-__data__-embedded-data/&amp;title=Ruby+__DATA__+%28embedded+data%29" 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/22/ruby-__data__-embedded-data/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Ruby+__DATA__+%28embedded+data%29+-+http://b2l.me/bmu5a+" 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/22/ruby-__data__-embedded-data/&amp;h=Ruby+__DATA__+%28embedded+data%29" 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/22/ruby-__data__-embedded-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

