Ruby¼Ì³Ð
¾ÅͲһÌõ
Ruby ÀàµÄ¼Ì³Ð
¹Ø¼ü×Ö: Ruby ÀàµÄ¼Ì³Ð
Ò»¡¢ÆÕͨ·½Ê½µÄ¼Ì³Ð
RubyÖ»Ö§³Öµ¥¼Ì³Ð
ruby ´úÂë
class
Child < Father
......
end
ObjectÊÇËùÓÐÀàµÄʼ×棬²¢ÇÒObjectµÄʵÀý·½·¨¶ÔrubyµÄËùÓжÔÏó¶¼ÊÇ¿ÉÓõġ£
superµÄʹÓãº
1¡¢ÔÚinitializeÖÐʹÓÃsuper£¬½«µ÷ÓÃÆ丸ÀàµÄinitialize·½·¨
2¡¢ÔÚÒ»°ãµÄʵÀý·½·¨ÖÐʹÓ㬽«µ÷ÓÃÆ丸ÀàÖÐͬÃûµÄ·½·¨¡£
ÏòÒ»¸ö¶ÔÏó·¢Ë͵÷Ó÷½·¨Ê±£¬rubyµÄ±¾Öʹý³ÌÈçÏ£º
1¡¢ruby½«¼ì²é¸Ã¶ÔÏóËùÊôµÄÀ࣬Èç¹û¸ÃÀàʵÏÖÁ˸÷½·¨£¬¾ÍÔËÐи÷½·¨
2¡¢Èç¹û¸ÃÀàûÓÐʵÏָ÷½·¨£¬ruby½«ÕÒµ½ÆäÖ±½Ó¸¸ÀàÖеķ½·¨£¬È»ºóÊÇÆä×游À࣬·²´ËÒÔÍù×·ËÝÕû¸ö×æÏÈÁ´
3¡¢Èç¹û×îÖÕûÓÐÕÒµ½ºÏÊÊ·½·¨£¬ruby»á²úÉúÒ»¸öÌØÊâµÄÐÐΪ£¬Òý·¢Òì³£´íÎó
£¨×¢ÒâÕâÀ︸À࣬Èç¹û¸ÃÀàÖÐincludeÁËÒ»¸ömodule£¬ÔòrubyÈç¹ûÔÚ¸ÃÀàÖÐûÓÐÕÒµ½¸Ã·½·¨¶¨ÒåÊÇ£¬»á°Ñmoduleµ±³ÉÖ±½Ó¸¸Àࣩ
¶þ¡¢Mixin
Õâ¸öÊÇrubyÌṩ¸øÄ£¿éµÄ¹¦ÄÜ¡£ÀඨÒåÖУ¬Í¨¹ýincludeÒ»¸öÄ£¿é¡£µ±ÀàʹÓÃincludeºó£¬Ä£¿éµÄËùÓеÄʵÀý·½·¨£¨ºÍ³£Á¿£©ÔÚ¸ÃÀàÖоͿÉÒÔʹÓÃ
ÁË¡£ÏÂͼÏÔʾÁËÀàºÍmixinÄ£¿éÖ®¼äµÄ¹ØϵÆäÔÀíÊÇ£¬µ±Ò»¸öÀà°üº¬Ò»¸öÄ£¿éʱ£¬Ruby´´½¨ÁËÒ»¸öÖ¸Ïò¸ÃÄ£¿éµÄÄäÃû´úÀíÀ࣬²¢½«Õâ¸öÄäÃû´úÀí²åÈ뵽ʵʩ
°üº¬µÄÀàÖÐ×÷ΪÆäÖ±½Ó³¬Àà¡£´úÀíÀàÖаüº¬ÓÐÖ¸ÏòÄ£¿éʵÀý±äÁ¿ºÍʵÀý·½·¨µÄÒýÓá£Õâ¸ö´úÀíÀàÊÇΨһָÏòµ×²ãÄ£¿é£º¸Ä±äÄ£¿éÖÐij¸ö·½·¨µÄ¶¨Òå
Ëü½«¸Ä±äËùÓаüº¬¸ÃÄ£¿éµÄÀà¡£
×¢Ò⣺
1¡¢Ä£¿éºÍÀàµÄÇø±ðÔÚÓÚ£¬Ä£¿é²»ÄÜʵÀý»¯£¬À಻ÄÜinclude
2¡¢Èç¹ûÄ£¿éºÍÀ಻ÔÚͬһ¸öÎļþÖУ¬Èç¹ûҪʹÓÃinclude£¬ÔòÏÈʹÓÃrequire£¬°ÑÎļþÒýÈë¡£
3¡¢include²¢²»ÊǼòµ¥µÄ½«Ä£¿éµÄʵÀý±äÁ¿ºÍ·½·¨¿½±´µ½ÀàÖУ¬¶øÊÇ£¬ËüÊǽ¨Á¢Ò»¸öÓÉÀൽËù°üº¬Ä£¿éµÄÒýÓá£Èç¹û¶à¸öÀà
ÒýÓøÃÄ£¿é£¬¶¼½«Ö
Ïà¹ØÎĵµ£º
RubyºÍPythonµÄÓï·¨±È½Ï
ÆäʵRubyºÍPython·Ç³£½Ó½ü£¬±È´ó¶àÊý±ðµÄÓïÑÔÒª½Ó½üµÄ¶à£¬ËùÒÔϲ»¶ÓÃɶ¾ÍÓÃɶ£¨´óʵ»°£¬ËäȻҲÊÇ·Ï»°£©¡£Óï·¨ÉϵIJî±ðËäÈ»ÓÐÄÇôһµã£¬´ó²¿·ÖÊÇsyntax sugar£¬ÎÒ¶·µ¨ÉÔ΢Áм¸¸ö£¨pythonÎÒÒ²ÍüµÃ²î²»¶àÁË£¬²»¶ÔµÄ´ó¼Ò¾¡¹ÜÀ´±Þʬ°É£©£¬µ«ÊÇÖ÷Òª²îÒ컹ÊÇÉè¼Æ˼ÏëÉϵģºÁé»î ......
Õý³£Çé¿öÏ£¬rubyÈç¹û·¢ÏÖÎļþ¼ÐÖÐÓÐsystem£¬readonly£¬hideÀàÐ͵ÄÎļþ£¬ÔòÊDz»ÄÜÖ±½Óɾ³ý
ËûÃǵġ£ÈçºÎ½â¾öÄØ£¿
ÒÔÆäÈËÖ®µÀ»¹ÖÎÆäÈËÖ®Éí£¡
def dryf(fpath) #destroy file
x = Iconv.iconv('utf-8','gbk',fpath).to_s
%x{attrib -R -S -H \"#{Iconv.iconv('gbk','utf-8',x).to_s}\"}
f = File.new(f ......
°²×°»·¾³£º
OS£ºWindows XP
Ruby: Ruby1.9.1
Mysql: Mysql5.1.46 £¨username/password: root/root port:3306£©
Ruby-Mysql Driver: mysql-2.8.1-x86-mswin32.gem
£¨×¢£ºÓÃ2.7.3°æ±¾µÄÇý¶¯ÔÚ²âÊÔʱ»á³öÏÖ require"mysql"£¬ÕÒ²»µ½Ö¸¶¨Ä£¿é ´íÎó£©
IDE£ºRubyMine2.0.1
°²×°Ruby,RubyMine,MysqlµÄÊÂÏîÔÚÕâÀï¾Í²»¶à ......
ʹÓà will_paginate ½øÐзÖÒ³ºÍ¼òµ¥²éѯ
ÔÚÃüÁîÐÐÏÂʹÓà gem install will_paginate ÃüÁ³öÏÖÏÂÃæ½á¹û°²×°³É¹¦
´ò¿ª books_controller.rb (Äã×Ô¼ºµÄ¿ØÖÆÆ÷)
×¢Ê͵ô²éÕÒÈ«²¿µÄ·½·¨£¬Ê¹ÓÃÏÂÃæµÄ·½·¨£¬ÒѾ¼¯³É¸ù¾Ýtitle½øÐвéѯ
Ruby´úÂë
#@books = Book.all
@books = Book.pagina ......
ÏÈ·ÅÉÏÒ»¸öʵÀýµÄbatÎļþ,ÒªÇó¹ÜÀíÔ±ÌØȨÔËÐÐ:
@echo off
::CMDÀïÏÔʾ²ÊÉ«ÎÄ×Ö
chcp 437>nul&&graftabl 936>nul
if not exist CONFIG.NT copy %WinDir%\System32\CONFIG.NT CONFIG.NT
@cls
echo DEVICE=%WinDir%\System32\ANSI.SYS /x >%WinDir%\System32\CONFIG.NT
@echo.
command /cecho
com ......