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.

   1  % sudo gem install methopara --source http://merbi.st

Usage is as follows.

   1  >> require "rubygems"
   2  >> require "methopara"
   3  >> def foo(a,b=nil,&c) end
   4  >> method(:foo).parameters
   5  => [[: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

posted by Png genki on Wed 11 Feb 2009 at 10:35 with 1 comment
Contents
methopara: Method#parameters only for Ruby-1.9.1
Comments
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
瀧内元気: おお、チェックしてみます。thx! '11-12
overisland: Reeder for iPhone もこの UI を実装していますね。 '11-12
瀧内元気: その情報は見たのですが、以下のサイトによると、現在はまた必要になってるっぽいんですよね。 ... '11-12
tkawa: http://devcenter.heroku.com/articles/rails31_he... '11-12
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ