<?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>Programming &#38; technology &#187; Ruby &amp; Rails</title>
	<atom:link href="http://limborey.com/category/ruby-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://limborey.com</link>
	<description>some useful stuff related to Programming Language, Pattern &#38; technology</description>
	<lastBuildDate>Sun, 30 May 2010 08:07:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Mixin in Ruby</title>
		<link>http://limborey.com/2009/03/23/mixin-in-ruby/</link>
		<comments>http://limborey.com/2009/03/23/mixin-in-ruby/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 06:36:41 +0000</pubDate>
		<dc:creator>Borey</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://limborey.wordpress.com/?p=52</guid>
		<description><![CDATA[C++ allows developers to use multiple inheritance. Unlike C++, Ruby only allows developers to use single inheritance. But Ruby has mixin functionality, which allows code to be included from other modules.
Here&#8217;s sample code to demonstrate mixin:

module MixinFirst
	def mixin_first_display
		puts &#34;This is mixin first&#34;
	end
end

module MixinSecond
	def mixin_second_display
		puts &#34;This is mixin second&#34;
	end
end

class Base
	def inheritance_display
		puts &#34;This is inheritance&#34;
	end
end

class Child &#60; [...]]]></description>
			<content:encoded><![CDATA[<p>C++ allows developers to use multiple inheritance. Unlike C++, Ruby only allows developers to use single inheritance. But Ruby has mixin functionality, which allows code to be included from other modules.</p>
<p>Here&#8217;s sample code to demonstrate mixin:</p>
<pre class="brush: ruby;">
module MixinFirst
	def mixin_first_display
		puts &quot;This is mixin first&quot;
	end
end

module MixinSecond
	def mixin_second_display
		puts &quot;This is mixin second&quot;
	end
end

class Base
	def inheritance_display
		puts &quot;This is inheritance&quot;
	end
end

class Child &lt; Base
	include MixinFirst
	include MixinSecond
end

child = Child.new
child.mixin_first_display
child.mixin_second_display
child.inheritance_display
</pre>
<p>Sample result:</pre>
<table border="0" width="100%" bgcolor="#99ffff">
<tbody>
<tr>
<td>This is mixin first<br />
This is mixin second<br />
This is inheritance</td>
<td></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://limborey.com/2009/03/23/mixin-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inheritance in Ruby</title>
		<link>http://limborey.com/2009/03/20/inheritance-in-ruby/</link>
		<comments>http://limborey.com/2009/03/20/inheritance-in-ruby/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 04:58:50 +0000</pubDate>
		<dc:creator>Borey</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://limborey.wordpress.com/?p=49</guid>
		<description><![CDATA[Inheritance is one of Object-Oriented concept. Since Ruby is an Object-Oriented Programming, it has implemented the Inheritance functionality.


#intialize global variable
$value = 0

class Parent
    def parent_value
        $value = 5
    end
end

class Child &#60; Parent
    def child_value
        $value = 10
    end
end

child = Child.new

#calling parent_method using child object
base_value = child.parent_value

#calling child_method
derive_value = child.child_value

#display result
puts &#34;Here's parent value: [...]]]></description>
			<content:encoded><![CDATA[<p>Inheritance is one of Object-Oriented concept. Since Ruby is an Object-Oriented Programming, it has implemented the Inheritance functionality.</p>
<pre class="brush: ruby;">

#intialize global variable
$value = 0

class Parent
    def parent_value
        $value = 5
    end
end

class Child &lt; Parent
    def child_value
        $value = 10
    end
end

child = Child.new

#calling parent_method using child object
base_value = child.parent_value

#calling child_method
derive_value = child.child_value

#display result
puts &quot;Here's parent value: #{base_value}&quot;
puts &quot;Here's child value: #{derive_value}&quot;
</pre>
<p>Sample Result:</p>
<table border="0" width="100%" bgcolor="#99ffff">
<tbody>
<tr>
<td>Here&#8217;s parent value: 5<br />
Here&#8217;s child value: 10</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://limborey.com/2009/03/20/inheritance-in-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Encapsulation in Ruby</title>
		<link>http://limborey.com/2009/03/20/encapsulation-in-ruby/</link>
		<comments>http://limborey.com/2009/03/20/encapsulation-in-ruby/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 04:38:13 +0000</pubDate>
		<dc:creator>Borey</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://limborey.wordpress.com/?p=36</guid>
		<description><![CDATA[

class Encapsulation
    def get_value
        @value
    end

    def set_value value
        @value = value
        return nil
    end
end

encapsulation = Encapsulation.new
encapsulation.set_value(15)
puts encapsulation.get_value

In this code, you cannot mess around with the state of its variable @value. The only way you can access it is through get &#38; set method (get_value, set_value). This is the encapsulation
Sample Result



15



]]></description>
			<content:encoded><![CDATA[<pre class="brush: ruby;">

class Encapsulation
    def get_value
        @value
    end

    def set_value value
        @value = value
        return nil
    end
end

encapsulation = Encapsulation.new
encapsulation.set_value(15)
puts encapsulation.get_value
</pre>
<p>In this code, you cannot mess around with the state of its variable @value. The only way you can access it is through get &amp; set method (get_value, set_value). This is the encapsulation</p>
<p>Sample Result</pre>
<table border="0" width="100%" bgcolor="#99ffff">
<tbody>
<tr>
<td height="20">15</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://limborey.com/2009/03/20/encapsulation-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Variables in Ruby</title>
		<link>http://limborey.com/2009/03/19/variables-in-ruby/</link>
		<comments>http://limborey.com/2009/03/19/variables-in-ruby/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 08:35:04 +0000</pubDate>
		<dc:creator>Borey</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://limborey.wordpress.com/?p=25</guid>
		<description><![CDATA[Here just how&#8217;s  to declare global, class, instant, and local variables in Ruby:


$global_variable = &#34;global variable&#34;

class First
    @@class_variable = 0

    def display_global_variable
        puts &#34;#{$global_variable} access from class 'First'&#34;
    end

    def class_variable
        @@class_variable += 1
        puts &#34;value of class variable : #{@@class_variable}&#34;
    end
end   

class Second
    def initialize(id,name)
        @id = id # id is [...]]]></description>
			<content:encoded><![CDATA[<p>Here just how&#8217;s  to declare global, class, instant, and local variables in Ruby:</p>
<pre class="brush: ruby;">

$global_variable = &quot;global variable&quot;

class First
    @@class_variable = 0

    def display_global_variable
        puts &quot;#{$global_variable} access from class 'First'&quot;
    end

    def class_variable
        @@class_variable += 1
        puts &quot;value of class variable : #{@@class_variable}&quot;
    end
end   

class Second
    def initialize(id,name)
        @id = id # id is a local variable
        @name = name # name is a local variable
    end

    def display_global_variable
        puts &quot;#{$global_variable} access from class 'Second'&quot;
    end

    def display_instance_variable
        puts &quot;display value of instance variable id = #{@id}, name = #{@name} &quot;
    end
end

#instantiate object
first = First.new
second = Second.new(1, &quot;borey&quot;)

#Demonstrate on class variable
first.display_global_variable
second.display_global_variable
puts &quot;\n&quot;

#Demonstrate on class variable
first.class_variable
first.class_variable
puts &quot;\n&quot;

#Demonstrate on instance variable
second.display_instance_variable
</pre>
<p>Here&#8217;s the result after code is executed:</p>
<table border="0" width="100%" bgcolor="#99ffff">
<tbody>
<tr>
<td>global variable access from class &#8216;First&#8217;<br />
global variable access from class &#8216;Second&#8217;</p>
<p>value of class variable : 1<br />
value of class variable : 2</p>
<p>display value of instance variable id = 1, name = borey</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://limborey.com/2009/03/19/variables-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->
