ruby£º²é¿´°æ±¾£¬ÃüÁîÐÐÔËÐгÌÐò
ÔÎÄÁ¬½Ó£º http://hi.baidu.com/%B7%CF%B2%C5%CB%FB%B8%E7/blog/item/09c19411244152daf7039ec4.html
ͨ¹ýÃüÁîÐв鿴ruby°æ±¾ÐÅÏ¢£º
ruby -v
ÃüÁîÐÐÔËÐгÌÐò£º
·½·¨1.
ruby -e 'print "hello ruby"'
-e ±íʾ½«ºóÃæµÄÒ»ÐÐ×÷Ϊruby³ÌÐò
print ÊÇrubyµÄÒ»¸öÄÚÖú¯Êý
·½·¨2.½»»¥±àÒë»·¾³
irb £¨ÃüÁîÐÐÊäÈëºó£¬»á½øÈëµ½±àÒë»·¾³£©
print "hello ruby" £¨Ö´ÐÐprintÃüÁ
·½·¨3: Ö´ÐÐÎļþ
ruby xxx.rb
Ïà¹ØÎĵµ£º
<!--
/* 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 ......
PythonºÍRubyµÄ¶Ô±È£¬¾ÀÕýһЩÎó½â
ÏÂÃæÊÇÎÒÔÚ¿´Á½Æª¹ØÓÚPythonºÍRuby¶Ô±ÈµÄÎÄÕÂʱ£¬Ëù×÷µÄ¾ÀÕý£¬ÔÎͼÊǹ㷺Á÷Ðеģ¬±È½ÏºÃÕÒ¡£
------------------------------------------------------
¡¶rubyºÍpythonµÄ±È½Ï¡·¸üÕýÒ»µãÊÂÇé
1¡¢Îĵµ¡¢¿ªÔ´ÏîÄ¿¡¢¿âÖ§³Ö£¬ÕâЩ¶«Î÷Ruby²»Òª¸úPython±È£¬²»ÊǼ¸¸öÊýÁ¿¼¶µÄÎÊÌ⣬ºÎ±ØÃ²Ë ......
ÒòΪһ´ÎżȻµÄ»ú»á½Ó´¥ÁËRubyÓïÑÔ¡£È»ºóÏÂÔØÁËRuby Shoes¹¤¾ß¡£
·¢ÏÖRuby»¹ÊÇÂùÓÐȤµÄ¡£
»¨ÁËÒ»¶Îʱ¼äÊìϤÁËËüµÄÓï·¨¡£
ÏÂÃæÀ´ÊÔÊÔËüµÄÊó±ê¹¦ÄÜ¡£
Shoes.app do
#ͼƬ³õʼ»¯
@img = image "http://www.google.cn/intl/zh-CN/images/logo_cn.gif"
#ͼƬ¹ØÓÚÊó±êµÄµ÷ÓÃ
& ......
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
......
rubyÖÐ×Ô´øÊµÏÖ¹Û²ìÕßģʽµÄÀàobserver¡£¿ÉÒÔÀûÓÃËüÀ´ÊµÏÖ¹Û²ìÕßģʽ¡£
´úÂëÀý×Ó£º
# -*- coding: GB2312 -*-
require 'observer'
# ¹Û²ìÕßģʽ(ruby)µÄʹÓÃÀý×Ó
# ±»¹Û²ìÕßP
class PObservable
include Observable
end
# ¹Û²ìÕßA
class AObserver
# update·½·¨ÃûÊDZØÐëµÄÒªÓеÄ
def update(arg)
puts "AO ......