易截截图软件、单文件、免安装、纯绿色、仅160KB

ruby 语法

本文转自:
http://hi.baidu.com/24xinhui/blog/item/9f52dd34382e11325ab5f553.html
ruby-语法
2009年06月20日 星期六 上午 00:21
http://www.blogjava.net/xxllnnn/archive/2009/01/18/251762.html
http://www.cnblogs.com/cnblogsfans/archive/2009/01/24/1380804.html
__setobj__ (2009-7-14)
    将接受委托的对象变为obj
    SimpleDelegator.new(obj)
    生成一个对象, 它委托obj来执行自身所拥有的方法
alias 与 alias_method的区别 (2009-7-14)
    1. alias是Ruby的一个关键字,而alias_method是Module类的一个方法
    2. alias的参数就是方法本身(method identify),注意,不是字符串,也不是Symbol,alias_method的参数则是字符串或者symbol,并且使用逗号分隔。
    3. alias_method可以重定义,而alias则不能
    alias new_method_name old_method_name
    alias_method :new_method_name, :old_method_name
    alias_method 'new_method_name', 'old_method_name'
=~ 完成match匹配操作 (2009-7-13 0:48)
    正则匹配


相关文档:

Ruby On Rails 2.0.2源代码分析(3) named route


前言
  在《Routing的载入》中,我大致介绍了一下Rails中最简单的route是如何加载的。这篇文章,我将来讲一讲Rails系统中更为复杂的named route和与RESTful相关的resource是如何被加载的。为了不重复太多的笔墨,这篇文章将在前文的基础上进行,如果发现单独看此文时,有少许云里雾里,建议先看一看我的前篇文章:R ......

ruby随机在控制台显示字符串

require 'curses'
module Curses
def self.program
main_scr=init_screen
noecho
cbreak
curs_set(0)
main_scr.keypad=true
yield main_scr
end
end
Curses.program do |scr|
max_x=scr.maxx
max_y=scr.maxy
100.times do
scr.setpos(rand(max_y),rand(max_x))
......

Ruby继承 九筒一条

Ruby 类的继承
关键字: Ruby 类的继承


一、普通方式的继承
 Ruby只支持单继承
 
ruby 代码
class
 Child < Father
  

......   

end
  

    Object是所有类的始祖,并且Object的实例方法 ......

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 ......

ruby文件从命令行中接收参数(全局变量:ARGV)


下文转自:
http://www.cnblogs.com/watir/archive/2009/04/25/1443440.html
ruby文件从命令行中接收参数
在命令行方法执行ruby文件时,需要从命令行中传入参数,可以使用全局变量:ARGV
如有ruby 文件test.rb,内容如下:
1 def hello(a)
2   puts a
3 end

5  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号