<?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>My Thought Pot &#187; ruby</title>
	<atom:link href="http://www.mythoughtpot.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mythoughtpot.com</link>
	<description>Thoughts of a constantly evolving programmer</description>
	<lastBuildDate>Thu, 11 Feb 2010 05:52:50 +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>Serializing Objects in Ruby</title>
		<link>http://www.mythoughtpot.com/2008/05/24/serializing-objects-in-ruby/</link>
		<comments>http://www.mythoughtpot.com/2008/05/24/serializing-objects-in-ruby/#comments</comments>
		<pubDate>Sat, 24 May 2008 22:17:38 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.mythoughtpot.com/?p=6</guid>
		<description><![CDATA[Simple object serialization in ruby can be done using two core ruby modules Marshal and Base64. Here is how its done
Marshalizer.rb

class Marshalizer
  def self.dump(obj)
    return Base64.encode64(Marshal.dump(obj))
  end

  def self.load(str)
    return Marshal.load(Base64.decode64(str))
  end
end

Sample Usage

class SampleObj
  attr_accessor :title, :description
end

class MarshalizerTest &#60; Test::Unit::TestCase
  def test_serialization
  [...]]]></description>
			<content:encoded><![CDATA[<p>Simple object serialization in ruby can be done using two core ruby modules <a href="http://www.ruby-doc.org/core/classes/Marshal.html">Marshal</a> and <a href="http://www.ruby-doc.org/stdlib/libdoc/base64/rdoc/index.html">Base64</a>. Here is how its done</p>
<p><b>Marshalizer.rb</b></p>
<pre class="brush: ruby;">
class Marshalizer
  def self.dump(obj)
    return Base64.encode64(Marshal.dump(obj))
  end

  def self.load(str)
    return Marshal.load(Base64.decode64(str))
  end
end
</pre>
<p><b>Sample Usage</b></p>
<pre class="brush: ruby;">
class SampleObj
  attr_accessor :title, :description
end

class MarshalizerTest &lt; Test::Unit::TestCase
  def test_serialization
    article = SampleObj.new
    article.description = &quot;Test name&quot;
    article.title = &quot;Test title with 's&quot;
    serialzied_article = Marshalizer.dump(article)
    assert_not_nil serialzied_article, &quot;serialized article should not be nil&quot;
    puts serialzied_article
    new_article = Marshalizer.load(serialzied_article)
    assert new_article
    puts new_article.inspect
    assert_not_nil new_article, &quot;loaded article should not be nil&quot;
    assert_instance_of SampleObj, new_article, &quot;new_article should be of type article&quot;
    assert_equal(article.title, new_article.title)
  end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mythoughtpot.com/2008/05/24/serializing-objects-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Mobile Browser Detector (port of JMBD)</title>
		<link>http://www.mythoughtpot.com/2008/05/24/ruby-mobile-browser-detector-port-of-jmbd/</link>
		<comments>http://www.mythoughtpot.com/2008/05/24/ruby-mobile-browser-detector-port-of-jmbd/#comments</comments>
		<pubDate>Sat, 24 May 2008 21:53:37 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.mythoughtpot.com/?p=4</guid>
		<description><![CDATA[I have successfully ported Java Mobile Browser Detector to ruby. I am sure there are other existing utilities to achieve this but I found this to more simpler to understand and use. It works well with my mobile site Fundu.mobi developed on rails. I though it would be useful for someone so here is the [...]]]></description>
			<content:encoded><![CDATA[<p>I have successfully ported <a href="http://www.javabeans.mobi/web/project_jmbd.jsp">Java Mobile Browser Detector</a> to ruby. I am sure there are other existing utilities to achieve this but I found this to more simpler to understand and use. It works well with my mobile site <a href="http://fundu.mobi">Fundu.mobi</a> developed on rails. I though it would be useful for someone so here is the code <a href="http://www.mythoughtpot.com/wp-content/uploads/2008/05/rmbd.zip">rmbd.zip</a>.</p>
<p>Here is how you can use it in any controller</p>
<pre class="brush: ruby;">
class SampleController &lt; ApplicationController
def index
device_config = DeviceConfigDetector.detect_capabilities_for_request(request);
logger.debug(&quot;device config = #{device_config.inspect}&quot;)
end
end
</pre>
<p><strong>UPDATE</strong>: This is now hosted as ruby gem available at <a href="http://github.com/kiranmeduri/rmbd/tree/master">http://github.com/kiranmeduri/rmbd/tree/master</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mythoughtpot.com/2008/05/24/ruby-mobile-browser-detector-port-of-jmbd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
