Yesterday (Feb 10, 2009),
asakusa.rb
took place at Akihabara, Tokyo.
asakusa.rb is a rubyist community that is based on Asakusa.
In the monthly meet-up of that community,
@ko1_twitter wrote a code snippet.
This snippet is a kind of backport of Method#parameters for Ruby-1.9.1.
His quick job led a way for merbists to change merb to be corresponding to Ruby-1.9.1.
He named his work "methopara". It stands for METHOd PARAmeters.
And I made it as a gem
for ease of use.
Now we can use it by the command below.
pre>>
% sudo gem install methopara --source http://merbi.st
<<--
Usage is as follows.
ruby>>
require "rubygems"
require "methopara"
def foo(a,b=nil,&c) end
method(:foo).parameters
=> [[:req, :a], [:opt, :b], [:block, :c]]
<<--
This gem is only for Ruby-1.9.1.
Because Ruby18x have merb-action-args, and Ruby-1.9.2 and its successors will have built-in Method#parameters.
Enjoy!
See Also