Created
November 3, 2011 15:06
-
-
Save pasberth/1336718 to your computer and use it in GitHub Desktop.
実行時に動的に関数名を得る
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Kernel | |
| def funcname | |
| caller[0] =~ /^.*?\:in `(.*?)'$/ | |
| $1.to_sym | |
| end | |
| end | |
| if __FILE__ == $PROGRAM_NAME | |
| require "test/unit" | |
| class T < Test::Unit::TestCase | |
| def test_0 | |
| assert_equal :test_0, funcname | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment