Óà 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
Ïà¹ØÎĵµ£º
Ó¢ÎÄ×ÊÔ´£º
http://www.ruby-lang.org/
http://www.ruby-doc.org£¨·ÃÎʲ»µ½¿ÉÓÃÏÂÃæµÄÍøÖ··ÃÎÊ£©£º
http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.ruby-doc.org
http://rubyforge.org/
http://www.ruby-forum.org/bb
http://www.rubygarden.org/ruby
http://www.rubyxml.com/
http://www.pragmaticprogra ......
1£ºFXRuby is a library for developing powerful and sophisticated cross-platform graphical user interfaces (GUIs) for your Ruby applications. It¡¯s based on the FOX Toolkit, a popular open source C++ library developed by Jeroen van der Zijp. What that means for you as an application developer is that ......
¶¨Òå
¡¡RoRÊÇRuby on RailsµÄËõд¡£Ruby on RailsÊÇÒ»¸öÓÃÓÚ±àÐ´ÍøÂçÓ¦ÓóÌÐòµÄ¿ò¼Ü£¬Ëü»ùÓÚ¼ÆËã»úÈí¼þÓïÑÔRuby£¬¸ø³ÌÐò¿ª·¢ÈËÔ±Ìṩǿ´óµÄ¿ò¼ÜÖ§³Ö¡£Ruby on Rails°üÀ¨Á½²¿·ÖÄÚÈÝ£ºRubyÓïÑÔºÍRails¿ò¼Ü¡£
ʲôÊÇRuby?
¡¡¡¡Ruby ÓïÑÔÊÇÒ»ÖÖ¶¯Ì¬ÓïÑÔ£¬ËüÓëPython¡¢SmalltalkºÍPerlÕâ3ÖÖ±à³ÌÓïÑÔÓÐЩÀàËÆ¡£RubyÓïÑÔÆðÔ´ÓÚÈ ......
Ruby 101£º¶ÔÏóºÍ·½·¨
Written by Allen Lee
´Ó¾²Ì¬·½·¨ËµÆð
ÔÚÉÏһƪÎÄÕÂĩ⣬ÎÒÃÇÌáµ½ÁËÊܱ£»¤µÄ¾²Ì¬·½·¨……Êܱ£»¤µÄ¾²Ì¬·½·¨£¿£¿RubyµÄprotected²»ÊÇÓÃÀ´ÏòÏàͬÀàÐ͵IJ»Í¬ÊµÀý¿ª·ÅÊÜÏÞ·½·¨µÄ·ÃÎʵÄÂð£¨Íü¼ÇprotectedµÄÓ÷¨ÁË£¿²»Òª½ô£¬»ØÈ¥ÉÏһƪÎÄÕ¸´Ï°Ò»Ï°ɡ££© ......