<?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>Carlan+Calazans &#187; ruby</title>
	<atom:link href="http://carlancalazans.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://carlancalazans.com</link>
	<description>{ Às vezes eu sonho com códigos }</description>
	<lastBuildDate>Thu, 22 Apr 2010 03:20:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ruby calculando o dia da Páscoa</title>
		<link>http://carlancalazans.com/ruby-calculando-o-dia-da-pascoa/</link>
		<comments>http://carlancalazans.com/ruby-calculando-o-dia-da-pascoa/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 23:06:46 +0000</pubDate>
		<dc:creator>Carlan Calazans</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[aprendizado]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[dica]]></category>
		<category><![CDATA[rapidinha]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://carlancalazans.com/?p=209</guid>
		<description><![CDATA[A Páscoa é uma data comemorativa que serve de referência para datas comemorativas móveis como Carnaval, Quaresma, Corpus Christ e outras. Por isso é importante saber quando a Páscoa vai ser comemorada. Além de interessante, serve como uma brincadeira para os garotos(as) de programa de plantão que não tem nada para fazer no feriado.
Cálculo
No total [...]]]></description>
			<content:encoded><![CDATA[<p>A Páscoa é uma data comemorativa que serve de referência para datas comemorativas móveis como Carnaval, Quaresma, Corpus Christ e outras. Por isso é importante saber quando a Páscoa vai ser comemorada. Além de interessante, serve como uma brincadeira para os garotos(as) de programa de plantão que não tem nada para fazer no feriado.</p>
<h4>Cálculo</h4>
<p>No total são três formas de calcular a data da Páscoa. A primeira é recorrendo a uma tabela, a segunda é através ao algorítimo de Gauss para o intervalo de anos que se inicia em 1900 e termina em 2099 e a terceira com o algorítimo de Meeus / Jones / Butcher. Como exemplo, optei pela segunda forma por ter umas condições e por ela ser mais elaborada. Para quem se interessar, os algorítimos serão relacionados no final deste texto.</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span><br />
<br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'date'</span><br />
<br />
FIELDS = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#123;</span>Carnaval Pascoa Corpus\ Christ<span style="color:#006600; font-weight:bold;">&#125;</span><br />
<br />
ano = <span style="color:#006666;">2009</span> <span style="color:#008000; font-style:italic;">#change me</span><br />
<br />
x = <span style="color:#006666;">24</span><br />
y = <span style="color:#006666;">5</span><br />
<br />
a = ano <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">19</span><br />
b = ano <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">4</span><br />
c = ano <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">7</span><br />
d = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">19</span> <span style="color:#006600; font-weight:bold;">*</span> a <span style="color:#006600; font-weight:bold;">+</span> x<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">30</span><br />
e = <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">*</span> b <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">4</span> <span style="color:#006600; font-weight:bold;">*</span> c <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">6</span> <span style="color:#006600; font-weight:bold;">*</span> d <span style="color:#006600; font-weight:bold;">+</span> y<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">7</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>d <span style="color:#006600; font-weight:bold;">+</span> e <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#008000; font-style:italic;">#april</span><br />
&nbsp; dia = d <span style="color:#006600; font-weight:bold;">+</span> e <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#006666;">9</span><br />
&nbsp; mes = <span style="color:#006666;">4</span><br />
<br />
&nbsp; <span style="color:#008000; font-style:italic;">#exceptions &nbsp;</span><br />
&nbsp; dia = <span style="color:#006666;">19</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>dia == <span style="color:#006666;">26</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; dia = <span style="color:#006666;">18</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>dia == <span style="color:#006666;">25</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> d == <span style="color:#006666;">28</span> <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> a <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#9966CC; font-weight:bold;">else</span><br />
&nbsp; <span style="color:#008000; font-style:italic;">#march</span><br />
&nbsp; dia = d <span style="color:#006600; font-weight:bold;">+</span> e <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">22</span><br />
&nbsp; mes = <span style="color:#006666;">3</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
dt = <span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>ano, mes, dia<span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
result = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
result <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> dt <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#006666;">47</span><br />
result <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> dt<br />
result <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> dt <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">60</span><br />
<br />
FIELDS.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>d<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{d}: #{result.shift.strftime(&quot;</span><span style="color:#006600; font-weight:bold;">%</span>d<span style="color:#006600; font-weight:bold;">-%</span>m<span style="color:#006600; font-weight:bold;">-%</span>Y<span style="color:#996600;">&quot;)}&quot;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Este texto tem uma pegadinha. Na verdade, meu intuito com ele não é ensinar Ruby nem mostrar como se calcula o dia da Páscoa. Foi uma forma que encontrei de mostrar como a linguagem chega perto do idioma, como poucas linguagens o fazem. Qualquer pessoa é capaz de entender as fórmulas matemáticas e relacioná-las com o exemplo mostrado. Sim, existe um açúcar, mas é fácil de entendê-lo também.</p>
<p>A maior parte do tempo, parece que estamos conversando com um editor de textos.</p>
<h4>Referências:</h4>
<ul>
<li><a href="http://pt.wikipedia.org/wiki/P%C3%A1scoa">Páscoa</a></li>
<li><a href="http://pt.wikipedia.org/wiki/C%C3%A1lculo_da_P%C3%A1scoa">Cálculo da Páscoa</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://carlancalazans.com/ruby-calculando-o-dia-da-pascoa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rapidinha: GIF animado com Ruby</title>
		<link>http://carlancalazans.com/rapidinha-gif-animado-com-ruby/</link>
		<comments>http://carlancalazans.com/rapidinha-gif-animado-com-ruby/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 19:50:15 +0000</pubDate>
		<dc:creator>Carlan Calazans</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[aprendizado]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[dica]]></category>
		<category><![CDATA[rapidinha]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://carlancalazans.com/?p=203</guid>
		<description><![CDATA[A algumas horas atrás estava tentando criar um gif animado para o twitter. Esbarrei com uma solução usando Gimp, sugestão do oráculo. Fiz o gif animado. Alguns minutos depois, o lembrei de uma gem para Ruby chamada RMagick para processamento de imagens. Como nunca a tinha experimentado eis que veio a idéia de escrever uma [...]]]></description>
			<content:encoded><![CDATA[<p>A algumas horas atrás estava tentando criar um gif animado para o <a href="http://twitter.com/carlancalazans">twitter</a>. Esbarrei com uma <a href="http://azulebanana.com/bluey/2007/04/30/simples-faixa-animada-em-gif-com-o-gimp/">solução</a> usando <a href="http://www.gimp.org/">Gimp</a>, sugestão do oráculo. Fiz o gif animado. Alguns minutos depois, o lembrei de uma gem para <a href="http://http://www.ruby-lang.org/">Ruby</a> chamada <a href="http://rmagick.rubyforge.org/">RMagick</a> para processamento de imagens. Como nunca a tinha experimentado eis que veio a idéia de escrever uma classe para criar um gif animado.</p>
<p>A gem RMagick é baseada na biblioteca de imagens <a href="http://www.imagemagick.org/">Image Magick</a> comumente conhecida no mundo Linux pelo poder de seus utilitários em linha de comando. É, linha de comando, sem a necessidade de Gimp, FW, PS e similares. Quem nunca ouviu falar de import ou convert? <img src='http://carlancalazans.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>A classe em questão é a:</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'RMagick'</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">include</span> Magick<br />
<br />
<span style="color:#9966CC; font-weight:bold;">class</span> AnimatedGif<br />
<br />
&nbsp; DELAY = <span style="color:#006666;">100</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">LOOP</span> = <span style="color:#006666;">0</span><br />
&nbsp; <br />
&nbsp; attr_accessor <span style="color:#ff3333; font-weight:bold;">:source</span><br />
<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> save<span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; load_files<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@list</span>.<span style="color:#9900CC;">delay</span> = DELAY<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@list</span>.<span style="color:#9900CC;">iterations</span> = <span style="color:#CC0066; font-weight:bold;">LOOP</span><br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@list</span>.<span style="color:#9900CC;">write</span><span style="color:#006600; font-weight:bold;">&#40;</span>file<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
&nbsp; private<br />
<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> load_files<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@list</span> = ImageList.<span style="color:#9900CC;">new</span><br />
&nbsp; &nbsp; <span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>source<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">entries</span>.<span style="color:#9900CC;">reject</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> f =~ <span style="color:#006600; font-weight:bold;">/</span>^\.<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@list</span>.<span style="color:#9900CC;">read</span> <span style="color:#996600;">&quot;#{source}/#{f}&quot;</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;">#Usage:</span><br />
gif = AnimatedGif.<span style="color:#9900CC;">new</span><br />
gif.<span style="color:#9900CC;">source</span> = <span style="color:#996600;">'img_src'</span><br />
gif.<span style="color:#9900CC;">save</span> <span style="color:#996600;">'/tmp/animated.gif'</span></div></div>
<p>O delay entre as imagens está fixo no código. O loop é infinito, ou seja, seu gif ficará se repetindo a vida toda. Após criar um objeto da classe AnimatedGif é necessário informar um diretório com imagens estáticas para gerar o gif animado. E por último, é só chamar o método save passando o caminho do arquivo gif final.</p>
<p>Demorou uns dois minutos a mais depois do entendimento da solução em Gimp para gerar esta classe em Ruby. Foram uns 3 minutos para entender a técnica do Gimp e 5 minutos para criar a classe em Ruby. A linguagem não morde!</p>
]]></content:encoded>
			<wfw:commentRss>http://carlancalazans.com/rapidinha-gif-animado-com-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acessando o Cep Livre com Ruby</title>
		<link>http://carlancalazans.com/acessando-o-cep-livre-com-ruby/</link>
		<comments>http://carlancalazans.com/acessando-o-cep-livre-com-ruby/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 01:00:17 +0000</pubDate>
		<dc:creator>Carlan Calazans</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[aprendizado]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://carlancalazans.com/?p=87</guid>
		<description><![CDATA[A (PC)² consultoria lançou um serviço chamado Cep Livre a algumas semanas atrás. O serviço tem por objetivo fornecer informações sobre CEPs brasileiros. O funcionamento é similar aos serviços já existentes, você faz uma chamada em uma URL e recebe os dados em um formato que escolher (XML ou CSV). Acredito que não vai demorar [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://www.pc2consultoria.com">(PC)² consultoria</a> lançou um serviço chamado <a href="http://ceplivre.pc2consultoria.com">Cep Livre</a> a algumas semanas atrás. O serviço tem por objetivo fornecer informações sobre CEPs brasileiros. O funcionamento é similar aos serviços já existentes, você faz uma chamada em uma URL e recebe os dados em um formato que escolher (XML ou CSV). Acredito que não vai demorar para fornecerem o formato JSON já que ele é amplamente utilizado hoje em dia, inclusive em aplicações móveis (XML não pelo-amor-de-deus).</p>
<p>A diferença em relação aos serviços que conheço é a possibilidade de adicionar um CEP a base de dados preenchendo <a href="http://ceplivre.pc2consultoria.com/index.php?module=cep&amp;event=formeditacep">um formulário</a>, ou seja, qualquer um pode fazer. Ah, o mais importante, o serviço é gratuito e a <a href="http://www.pc2consultoria.com">(PC)² consultoria</a> afirma que não tem intenção de cobrar pelo serviço no <a href="http://www.pc2consultoria.com/index.php?option=com_content&amp;task=view&amp;id=298&amp;Itemid=73">website deles</a>.</p>
<p>Agora a parte divertida. Fiz uma classe que busca as informações de CEP, faz o parser e apresenta em dois formatos: Array e Hash.</p>
<div class="codecolorer-container ruby vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span><br />
<br />
<span style="color:#008000; font-style:italic;"># 9/2/2009</span><br />
<span style="color:#008000; font-style:italic;"># Carlan Calazans (carlancalazans at gmail.com)</span><br />
<br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/http'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rexml/document'</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">class</span> CepLivre<br />
<br />
&nbsp; URL_CEP_LIVRE = <span style="color:#996600;">'http://ceplivre.pc2consultoria.com/index.php?module=cep&amp;formato=xml&amp;cep='</span><br />
&nbsp; FIELDS = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>tipo_logradouro logradouro bairro cidade estado_sigla<span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>cep<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@cep</span> = cep<br />
&nbsp; &nbsp; get_data<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> to_array<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@result</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; process_a<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> to_hash<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@result</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><br />
&nbsp; &nbsp; process_h<br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <br />
&nbsp; private<br />
&nbsp; <br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> get_data<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@data</span> = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">get_response</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">URI</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{URL_CEP_LIVRE}#{@cep}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;Connection error.&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#0066ff; font-weight:bold;">@data</span>.<span style="color:#9900CC;">kind_of</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">Net::HTTPSuccess</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@xml</span> = <span style="color:#6666ff; font-weight:bold;">REXML::Document</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>@data.<span style="color:#9900CC;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> process_a<br />
&nbsp; &nbsp; FIELDS.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; field = <span style="color:#6666ff; font-weight:bold;">REXML::XPath</span>.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>@xml, <span style="color:#996600;">&quot;//#{f}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">first</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@result</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> field.<span style="color:#9900CC;">text</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@result</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> process_h<br />
&nbsp; &nbsp; FIELDS.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; field = <span style="color:#6666ff; font-weight:bold;">REXML::XPath</span>.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>@xml, <span style="color:#996600;">&quot;//#{f}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">first</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@result</span><span style="color:#006600; font-weight:bold;">&#91;</span>f<span style="color:#006600; font-weight:bold;">&#93;</span> = field.<span style="color:#9900CC;">text</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; &nbsp; <span style="color:#0066ff; font-weight:bold;">@result</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Array</span><br />
<span style="color:#CC0066; font-weight:bold;">puts</span> CepLivre.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;29040-470&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_array</span><br />
<span style="color:#008000; font-style:italic;"># Hash</span><br />
<span style="color:#CC0066; font-weight:bold;">puts</span> CepLivre.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;29040-470&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_hash</span></div></div>
<h4>[Update]</h4>
<p>Faça o download da versão <a href="http://files.carlancalazans.com/ruby/ceplivre/ceplivre-rexml.rb">rexml</a> e <a href="http://files.carlancalazans.com/ruby/ceplivre/ceplivre-libxml.rb">libxml-ruby</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://carlancalazans.com/acessando-o-cep-livre-com-ruby/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Ruby Learning novos cursos</title>
		<link>http://carlancalazans.com/ruby-learning-novos-cursos/</link>
		<comments>http://carlancalazans.com/ruby-learning-novos-cursos/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 01:26:29 +0000</pubDate>
		<dc:creator>Carlan Calazans</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[aprendizado]]></category>
		<category><![CDATA[curso]]></category>
		<category><![CDATA[pesquisa]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby learning]]></category>

		<guid isPermaLink="false">http://carlancalazans.com/?p=11</guid>
		<description><![CDATA[Ruby Learning é um website que oferece cursos baseados em Ruby online, em inglês. O curso em si é muito divertido e muito bem feito para ser um curso online e de graça, até os exercícios são bem bolados. Há a possibilidade dos alunos se interagirem uns com os outros através de fóruns e com [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.rubylearning.org" target="_self">Ruby Learning</a> é um website que oferece cursos baseados em <a href="http://www.ruby-lang.org" target="_self">Ruby</a> online, em inglês. O curso em si é muito divertido e muito bem feito para ser um curso online e de graça, até os exercícios são bem bolados. Há a possibilidade dos alunos se interagirem uns com os outros através de fóruns e com os Assistentes de professor, que nada mais são do que alunos mais experientes. O conteúdo de um lição é liberado todo o Sábado, o aluno tem a semana inteira para estudar e fazer os exercícios, é bem tranquilo. Outro incentivo é que o curso é curto, ou seja, tem duração de somente 2 meses.</p>
<p>Aproveitando, o Satish criou uma pesquisa para a criação de novos cursos. O Ruby Learning já tem algumas sugestões e deseja saber o que a comunidade pensa sobre isto. Portanto, citando o Satish em seu blog:</p>
<blockquote><p>We’re rapidly expanding our course offerings here at RubyLearning, trying to keep up with the enormous and ever-growing interest in Ruby. But we need your YOUR help because, as you know, Ruby is a big subject, and we’d like to be sure to focus in on the areas of most interest to you. (<a href="http://rubylearning.com/blog/2008/11/15/can-you-help-rubylearning-with-your-suggestions/" target="_self">link para a pesquisa</a>).</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://carlancalazans.com/ruby-learning-novos-cursos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
