require 'main'
Main {
mode 'install' do
def run() puts 'installing...' end
end
mode 'uninstall' do
def run() puts 'uninstalling...' end
end
}
上面是这个gem的用法
Main后直接跟block
如果Main.xxx 可以理解 这是一个method
可是Main直接跟,让我不能理解啊
https://github.com/ahoward/main/blob/master/lib/main/factories.rb
代码快只能在函数调用后面,所以Main应该是main里面的一个不带参数的函数
:D 定义类的时候需要关键字class,在Ruby中能使用大括号的情况很少,还有list,hash-constructor也用,其他情况你可以到
http://ruby-std.netlab.jp/draft_spec/agreement.html
下载Ruby的语言规范