RubyµÄ×°ÊÎÆ÷ģʽʵÏÖ
class Tree
def initialize
puts "Make a normal tree"
end
def decorate
puts "Make sure the tree won\'t fall"
end
end
class RedBalls < Tree
def initialize(tree)
@parent = tree;
end
def decorate
@parent.decorate
puts "Put on some red balls"
end
end
class BlueBalls < Tree
def initialize(tree)
@parent = tree;
end
def decorate
@parent.decorate
puts "Add blue balls"
end
end
class Angel < Tree
def initialize(tree)
@parent = tree;
end
def decorate
@parent.decorate
puts "An angel on the top"
end
end
tree = Angel.new(BlueBalls.new(RedBalls.new(Tree.new)))
tree.decorate
Ïà¹ØÎĵµ£º
Ruby 101£º·½·¨¶ÔÏó
Written by Allen Lee
´Ó·½·¨µ÷ÓÃ˵Æð
ÔÚÉÏһƪÎÄÕÂÀÎÒÃÇ¿´µ½µ÷ÓöÔÏóµÄ·½·¨ÊµÖÊÉÏÊÇÏò¶ÔÏó·¢ËÍÏûÏ¢£¬ÏÂÃæ£¬ÎÒÃÇÔÙÀ´¿´Ò»¸öÓÐȤµÄÓ¦Óá£ÔÚRubyÀ×Öµä¿ÉÒÔͨ¹ý {key => value} À´´´½¨£¬Èç¹ûÄãʹÓõİ汾ÊÇ1.9»òÒÔÉÏ£¬µ±keyµÄÀàÐÍÊÇSymbolʱ£¬´´½¨×ÖµäµÄÓ ......
While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file c ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
{font-family:"Cambria Mat ......
Ruby 101£º¶¯Ì¬±à³Ì
Written by Allen Lee
µ±method_missingµÄħ·¨Ê§Ð§Ê±……
ÔÚÉÏһƪÎÄÕÂÀÎÒÃÇͨ¹ýÖØÐ´HashÀàµÄmethod_missing·½·¨°ÑHash¶ÔÏóÄ£Äâ³ÉÄäÃû¶ÔÏ󣬵«ÊÇ£¬ÕâÖÖ×ö·¨ÓÐʱ»á²úÉúһЩĪÃûÆäÃîµÄÎÊÌ⣬¾Ù¸öÀý×Ó°É£¬¼ÙÈçÎÒ°Ñprocess·½·¨£¨ÍêÕûʵÏֲμûÉÏһƪÎÄÕ ......