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

Comments:

Face rogerdpack almost 5 years ago.

Thanks for doing that

or Preview
Social Bookmarks
  • Delicious
  • B_entry1289
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ