½»»¥Ê½ Ruby Shell irb
irb ÊÇ´ÓÃüÁîÐÐÔËÐеÄ
irb µÄÃüÁîÐÐÑ¡Ïժ×Ô¡¡Porgramming Ruby µÚ¶þ°æ£©
-f
½ûÖ¹¶ÁÈ¡~/.irbrc¡¡Suppress reading ~/.irbrc.
-m
Êýѧģʽ£¨Ö§³Ö·ÖÊýºÍ¾ØÕ󣩡¡Math mode (fraction and matrix support is available).
-d
ÉèÖÃ#DEBUGΪtrue(ͬruby -dÒ»Ñù)¡¡¡¡Set $DEBUG to true (same as ``ruby -d'').
-r load-module
ͬruby -r¡¡Same as ``ruby -r''.
--inspect
ʹÓÃObject#inspectÀ´¸ñʽ»¯Êä³ö£¨Ä¬ÈÏ·½Ê½£¬³ýÊýѧģʽÍ⣩¡¡Use ``inspect'' for output (the default, unless in math mode).
--noinspect
²»Ê¹ÓÃinspect½øÐÐÊä³ö¡¡Do not use inspect for output.
--readline
ʹÓÃReadlineÀ©Õ¹Ä£¿é¡¡Use Readline extension module.
--noreadline
²»Ê¹ÓÃReadlineÀ©Õ¹Ä£¿é¡¡Do not use Readline extension module.
--prompt prompt-mode
Çл»Ìáʾ·û¡£Ô¤¶¨ÒåµÄģʽ°üÀ¨£¨null,default,simple,xmpÒÔ¼°inf-ruby£©¡¡Switch prompt mode. Predefined prompt modes are ``default'', ``simple'', ``xmp'', and ``inf-ruby''.
--prompt-mode prompt-mode
Same as --prompt.
--inf-ruby-mode
ÉèÖÃirbÒÔEmacsµÄinf-ruby-modeģʽÔËÐУ¬¸ü¸ÄÌáʾ·û²¢·ÏÖ¹-readline¡¡Sets up irb to run in inf-ruby-mode under Emacs. Changes the prompt and suppresses --readline.
--simple-prompt
ʹÓüòµ¥µÄÌáʾ·û¡¡Simple prompt mode.
--noprompt
²»ÏÔʾÌáʾ·û¡¡Do not display a prompt.
--tracer
ÏÔʾÃüÁîÖ´Ðеĸú×Ù¡¡Display trace for execution of commands.
--back-trace-limit n
ÏÔʾ×î¶¥²¿ºÍβ²¿µÄnÏî»ØËÝÐÅÏ¢¡£Ä¬ÈÏֵΪ16¡¡Display backtrace information using the top n and last n entries. The default value is 16.
--irb_debug n
½«ÄÚ²¿µ÷ÊÔ¼¶±ðÉèÖÃΪn(Ö»¶ÔirbµÄ¿ª·¢ÓÐÓã©¡¡Set internal debug level to n (only for irb development).
-v, --version
ÏÔʾirbµÄ°æ±¾ºÅ¡¡Print the version of irb.
ÃüÁîÐпªÊ¼Ö´Ðкó£¬irbÏÔʾһ¸öÌáʾ·û²¢µÈ´ýÊäÈë¡£
ʹÓÃirbµÄĬÈÏÌáʾ·û£¬ËüÏÔʾµ±Ç°µÄ°ó¶¨¡¢Ëõ½ø£¨Ç¶Ì×£©¼¶±ðÒÔ¼°Ðкš£
È磺
C:\>irb
irb(main):001:0> elvuel="elvuel"
=> "elvuel"
irb(main):002:0> elvuel.class
=> String
¿ÉÒÔͨ¹ýexit »ò quit,»òÕßͨ¹ýÊäÈëÒ»¸öÎļþ½áÊø·ûºÅ£¨Èç¹ûûÓÐÉèÖÃIGNORE_EOFģʽ£©À´Í˳ö
Ïà¹ØÎĵµ£º
¶©µ¥´¦Öã¬Ê×ÏÈÒªÓÐÒ»¸ö¶©µ¥µÄÏêϸÁÐ±í£¨°üÀ¨ÊýÁ¿£¬¼ÛǮɶµÄ£©ºÍÒ»¸ö¶ÔÓÚ¸öÈ˵ÄһЩÐÅÏ¢µÄÒ»¸ö±í¡£Òò¶øÎÒÃÇ´´ÔìÁ½¸öÄ£ÐÍ£¬line_item(ÁбíÏî),order(Áбí)£¬Æäºó±àÕßÈç´Î
/db/migrate xxx_create_order xxx_line_item
Ruby´úÂë
Ò».class CreateOrders < ActiveRecord::Migration
¶þ.def self.up
3. create_tabl ......
¹«Ë¾ÀïÔ½À´Ô½¶àµÄ½Ó¿ÚÒÔICE·½Ê½ÌṩÁË£¬ÒÔǰû½Ó´¥¹ý£¬ËùÒÔÎÒÕâÁ½ÌìÒ²³éÁ˵ãʱ¼äÑо¿ÁËÏÂICE£¬²Î¿¼ÁËÍøÉϺܶàÌû×Ó£¬²ÅÖÕÓÚÅÜͨµÚÒ»¸ö¼òµ¥µÄICE
½ÓÏÂÀ´ÌùÉÏÎÒËùÓл·¾³µÄ´î½¨¹ý³ÌÒÔ¼°´úÂ룬ºÍ´ó¼Ò·ÖÏíÏÂICEËù´øÀ´µÄ¿ìÀÖ
ICEÊÇʲôÎҾͲ»¶à˵ÁË
1¡¢ Ò»¿î¸ßÐÔÄܵÄÖмä¼þ£¬»ùÓÚICE¿ÉÒÔʵÏÖµçÐż¶µÄ½ ......
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
......
ÔÚÂÛ̳Àï¿´ÁËdaquan198163ËùдµÄ¡¶³õѧRORµÄÒÉ»ó¡·ÕâÆªÎÄÕ£¬robbinÔڻظ´ÖиøÁËÏêϸµÄ½â´ð£¬¿ÉÊÇ¿´Íê½â´ðÖ®ºó£¬ÎÒÒ²²úÉúÁËһЩÒÉ»ó£¬ÔÚ´ËÏëÎÊÎÊ¡£
ÔÚrobbinËù¸ø³öµÄ½â´ðµ±ÖУ¬¸ü¶àµÄÊDzûÊörailsµÄºÃ´¦£¬È»¶ø´ó¼Ò¶¼ÖªµÀ£¬railsÖ»Ê ......
ÕÕÀý¿ÉÒÔÏÈ¿´¶Ë³ÌÐò
class Person
def initialize( name,age=18 )
@name = name
@age = age
@motherland = "China"
end
def talk
puts "my name is "+@name+", age is "+@age.to_s
&n ......