Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Óà Ruby ²È²ÈËÄÈ˰ï




ÉÏÉÏÖÜÔÚÊéµê¿´µ½Ò»±¾¡¶Ruby
Éè¼ÆÄ£Ê½¡·£¬¼ñÆðÀ´ 10 ·ÖÖÓ¿´Í꣬ÈÓÁË£¨±ðÎÊÎÒΪʲô……£©
ÏÂÃæÓÃ Ruby
ддÉè¼ÆÄ£Ê½£¬Ë³±ãÅúÒ»Åú Java ºÍ Gof
¡£
1.Factory
ºÍ Abstract Factory
class
 Factory  
  attr_accessor :product
  
  def
 produce  
    @product
.new
  
  end
  
end
  
class
 Product  
  #..
  
end
  
fac = Factory.new
  
fac.product = Product  
fac.produce  
class Factory
attr_accessor :product
def produce
@product.new
end
end
class Product
#..
end
fac = Factory.new
fac.product = Product
fac.produce
JavaдµÄ¹¤³§ÓÐÕâô¼òµ¥£¬ÕâôÈÝÒ×ÖØÓÃô£¿
2.Builder
# ¹¤Í·
  
class
 Director  
  def
 build_with builder  
    acc = ''
  
    [:header
, :body
, :footer
].each
 do
 |m|  
      acc += builder.__send__ m if
 builder.respond_to? m  
    end
  
    acc  
  end
  
end
  
# ¹¤ÈË
  
class
 HTMLBuilder  
  def
 header; '<html><title>html builder</title>'
;end
  
  def
 body;   '<body>html builder</body>'
        ;end
  
  def
 footer; '</html>'
                          ;end
  
end
 


Ïà¹ØÎĵµ£º

RUBY·ûºÅµÄÀí½â

1£ºÊÇSymbolÀàµÄʵÀý
2: ÊÇÃû³ÆµÄ¶ÔÏó
3£º·ûºÅÊDz»¿É¸Ä±äµÄ×Ö·û´®£¬Ò²²»¿É±»GCµÄ
4£ºÔÚ´ó¶àÊýÇé¿öÏ£¬½ÓÊÜ·ûºÅ×÷Ϊ²ÎÊýµÄ·½·¨Ò²ÄܽÓÊÜ×Ö·û´®£¬·´¹ýÀ´²»³ÉÁ¢£»
5£ºÓ÷ûºÅÒª±ÈÓÃ×Ö·û´®Ê¡ÄÚ´æ
6£ºÃ¿¸ö·ûºÅÔÚ¶ÔÏó¿Õ¼äÖÐÖ»³öÏÖÒ»´Î£ººÍFixnumÒ»Ñù£¬¶¼´æÎªÖ±½ÓÖµ
7£ºÓÐÒâ˼µÄSymbol#to_proc
r ......

ruby gui¿ª·¢

http://zh.wikipedia.org/wiki/WxWidgets ÖÐÎĵÄ
http://zh.wikipedia.org/zh-cn/WxWidgets ¼òÌåÖÐÎÄ
http://wxruby.rubyforge.org/wiki/wiki.pl?Using_GUI_Designers  
http://visualwx.altervista.org/   RAD http://www.wxwidgets.org/
http://wiki.wxwidgets.org/Main_Page ......

Ruby RSpec ³õ²½½Ó´¥

×î½üÒ»¶Îʱ¼ä£¬ÔÚæºõ£ò£õ£â£ùµÄ²âÊÔ¿ò¼Ü¡£
´Ó²»ÊìϤBDD,RSpecµ½Ä¿Ç°Äܹ»ÉÔ΢×öµã¶«Î÷£¬¸Ð¾õ·Ç³£²»´í¡£
RubyÊÇÃŷdz£Áé»îµÄ½Å±¾ÓïÑÔ£¬´Ó¶øÒ²×ÔÈ»ÏëÓÃËü×÷Ϊ²âÊԽű¾¡£ÈÃÎÒÃDZàдµÄ´úÂë½øÈë£Ô£Ä£ÄµÄģʽ¡£
µ±È»£Ô£Ä£Ä¾­¹ýÕâЩÄêµÄ·¢Õ¹£¬ÏÖÔÚÒѾ­½øÈëBDD(Behaviour-Driven Develop)µÄʱ´ú¡£
   BDDºÍTDDÖ÷ÒªµÄ× ......

RUBY ʵÏÖSOAP

SOAP ·þÎñ¶Ë£º
#!/usr/local/bin/ruby
require 'soap/rpc/standaloneServer'
module MySOAP
 class Timer
  def now
   Time.new.strftime("%Y-%m-%d %H:%M:%S")
  end
 end
 class Add
   def add(i, j)
  return i.to_i + j.to_i
&nb ......

RUBY EXCEL²Ù×÷

 ÓÃrubyн¨Ò»¸öexcelÎļþ£¬²¢ÇÒÉèÖÃһЩֵ¡£
 require 'win32ole'
excel = WIN32OLE.new("excel.application")       
excel.Visible = true
excel.WorkBooks.Open("d:\\test.xls")
excel.WorkSheets("sheet1").Activate
excel.Cells(2,3).value = "ÕÅÈý"
exce ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ