Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : Ruby

rubyÔÚwindows 7 cmd ÖÐÏÔʾ²ÊÉ«ÎÄ×Ö

ÏÈ·ÅÉÏÒ»¸öʵÀýµÄ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 
command /cecho hello world
command /cecho  µÇðÙȸ¥
@echo.
@echo.
command /cecho  °×ÈÕÒÀɽ¾¡£¬»ÆºÓÈ뺣Á÷¡£
@echo.
command /cecho  ÓûÇîǧÀïÄ¿£¬¸üÉÏÒ»²ãÂ¥¡£
@echo.
@echo.
@echo.
@echo.
command /cecho  Ͻ­Áê
@echo.
@echo.
command /cecho  ³¯´Ç°×µÛ²ÊÔƼ䣬ǧÀï½­ÁêÒ»ÈÕ»¹¡£
@echo.
command /cecho  Á½°¶Ô³ÉùÌ䲻ס£¬ÇáÖÛÒѹýÍòÖØɽ¡£
@echo.
@echo.
command /cecho  ¼ÌÐøÏÂÒ³
pause>nul
@cls
@echo.
@echo.
@echo.
command /cecho  ......

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»á²úÉúÒ»¸öÌØÊâµÄÐ ......

RUBYʵ¼ù—´øÃÜÂë¼ÓÃܵÄÓû§´´½¨¼°ÐÞ¸Ä

¿ª·¢»·¾³
Ruby: Ruby1.9.1
Rails: Rails2.3.5
Mysql:Mysql5.0.9
Driver:mysql-2.8.1-x86-mingw32.gem
IDE:Rubymine2.0.1
Ò»¡¢´´½¨Êý¾Ý±íUsers
ÀûÓÃRubyMine×Ô´øµÄScaffold¹¤¾ß´´½¨Êý¾Ý±íUsers£¬Ò²¿ÉÒÔÊÖ¶¯´´½¨
¶þ¡¢´´½¨ControllerºÍView
RubyÏîÄ¿—>ÓÒ¼ü—>Create Model
Íê³Éºó½«×Ô¶¯Éú³ÉÏàÓ¦µÄÎļþ
Èý¡¢ÐÞ¸ÄModel user.rb
ÀûÓÃDigest/SHA1¶ÔÃÜÂë½øÐмÓÃÜ£¬ÊµÏÖ¼ÓÃܱ£´æ
Ð޸ĺó´úÂëÈçÏ£º
require "digest/sha1"
class User < ActiveRecord::Base
attr_accessor :hashed_password,:repassword
attr_accessible :username, :hashed_password, :repassword
validates_uniqueness_of :username
validates_presence_of :username, :hashed_password
def before_create
self.password = User.hash_password(self.hashed_password)
end
def after_create
@hashed_password = nil
end
def before_update
self.password = User.hash_password(self.hashed_password)
end
def after_update
@hashed_password = nil
end
private
def self.hash_password(hashed_password)
Digest ......

Rubyʵ¼ù—Óû§µÇ¼

¿ª·¢»·¾³
Ruby:Ruby1.9.1
Rails:Rails2.3.5
Mysql:Mysql5.0.9
Driver:mysql-2.8.1-x86-mingw32.gem
IDE:Rubymine2.0.1
Ò»¡¢´´½¨View/login
ÔÚView/loginÏ´´½¨login.html.erb¡¢index.html.erb¡¢loginFail.html.erb
login.html.erb´úÂëÈçÏ£º
<h1>Welcome to login!</h1>
<% form_tag do %>
<table>
<tr>
<td>User name:</td>
<td><%= text_field("user", "username") %></td>
</tr>
<tr>
<td>Password:</td>
<td><%= password_field("user", "hashed_password") %></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value=" login " /> <input type="reset" value=" reset " /></td>
</tr>
</table>
<% end %>

index.html.erb´úÂëÈçÏ£º
<h1>Choose a page to look!</h1>
<p><%= link_to 'Users', :controller=>"users",:action=>"in ......

Use lambda in Ruby ¾ÅͲһÌõ

http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/
Understanding Ruby Blocks, Procs and Lambdas
Blocks, Procs and lambdas (referred to as closures
in Computer Science) are one of the most powerful aspects of Ruby, and
also one of the most misunderstood. This is probably because Ruby
handles closures in a rather unique way. Making things more complicated
is that Ruby has four different ways of using closures, each of which is
a tad bit different, and sometimes nonsensical. There are quite a few
sites with some very good information about how closures work within
Ruby. But I have yet to find a good, definitive guide out there.
Hopefully, this tutorial becomes just that.
First Up, Blocks
The most common, easiest and arguably most “Ruby like” way to use
closures in Ruby is with blocks. They have the following familiar
syntax:
array
=
[
1
,
2
,
3
,
4
]

array
.
collect!
do
|
n
|
n
**
......

Watir Óï·¨£¨Web Application Testing in Ruby)

Watir Óï·¨£¨Web Application Testing in Ruby)
# watirµÄ°²×°
watieµÄ°²×°Çë²é¿´ -> Ruby libraryµÄ°²×°
# ʹÓÃWatir¹¤¾ß£¬ÐèÒªÔڽű¾ÖмÓÉÏ
require 'watir'
# ´´½¨Ò»¸öIEµÄʵÀý
ie = Watir::IE.new
»òÕßÔÚ´´½¨µÄͬʱֱ½Óתµ½Ò³Ãæ
ie = Watir::IE.start('http://www.text.com/')
WatirʹÓÃstart·½·¨Í¬Ê±´´½¨Ò»¸öä¯ÀÀÆ÷ʵÀý²¢×ªµ½Ò»¸öÒ³Ãæ¡£
IEä¯ÀÀËÙ¶È
ie.speed = :fast
ie.speed = :slow
# Ò³Ãæµ¼º½
ie.goto('http://www.text.com/')
×¢: ie.goto»¹¿ÉÒÔÔËÐÐjavascriptµÄ´úÂëÈç: ie.goto("javascript: ie.document.write("Hello World");")
# È¡µÃµ±Ç°ÍøÒ³µÄÍøÖ·
ie.url
# µã»÷³¬Á´½Ó
ie.link(:text , "Pickaxe").click
ie.link(:href, /http:\/\/pragmaticprogrammer\.com/).click
ie.link(:name => 'foo', :index => 1).click
# ³¬Á´½ÓµÄuri
ie.link(:text , "Pickaxe").href
ie.link(:index, 1).href
ie.link(:text => "reply", :index => 2).href
# ³¬Á´½ÓµÄÎı¾
ie.link(:href , /http:\/\/pragmaticprogrammer\.com/).text
¶ÔÓ¦µÄHTML´úÂëΪ£º
<a href='http://pragmaticprogrammer.com ......
×ܼǼÊý:146; ×ÜÒ³Êý:25; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [1] [2] [3] [4] 5 [6] [7] [8] [9] [10]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ