Get the name of the currently executing method

salt.racer

$0 is the variable for the top level Ruby program, but is there one for the current method?

Mark A. Nicolosi

Even better than my first answer you can use __method__:

class Foo
  def test_method
    __method__
  end
end

This returns a symbol – for example, :test_method. To return the method name as a string, call __method__.to_s instead.

Note: This requires Ruby 1.8.7.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get the name of the currently executing method in dotnet core

From Dev

Get the name of currently executing @Test method name in @BeforeMethod and @AfterMethod in testng

From Java

Getting the name of the currently executing method

From

Get the name of the currently executing testing test?

From Java

Get name of currently executing test in JUnit 4

From

Can you use reflection to find the name of the currently executing method?

From Java

How do I get the path and name of the file that is currently executing?

From Dev

How to get the fully-qualified name of the currently executing function?

From Dev

How do I get the name of the Scenario step currently executing?

From Dev

How to get interface implementation type for currently executing method?

From Dev

How To Get Name of Calling Method and Executing Method of Lambda Expression

From Java

Java : Getting the currently executing Method corresponding object

From Dev

Jenkins plugin - how to get currently executing job?

From Dev

Get name of currently logged in user

From Dev

Snowflake - how do I retrieve the name of the currently executing procedure?

From Dev

How to get the name of the executing type?

From Dev

Get the currently executing script element inside a type="module" script

From Javascript

How to get the file-path of the currently executing javascript code

From Java

How do I get the directory that the currently executing jar file is in?

From Dev

Get the path of the script that is currently executing in Steel Bank Common Lisp

From Dev

Get currently executing javascript line in react native javascript engine for debugging

From Dev

Use dbus to get name of mediaplayer currently playing

From Dev

How to get the name of the currently active window in Python?

From Dev

Get name of currently active thread in ThreadPoolExecutor android

From Dev

How to get name of currently loaded fxml file?

From Dev

Get the currently used protocol name from HttpServletRequest?

From Dev

Get the name of the state that is currently being transitioned to

From Dev

Get currently executed describe/test name

From Dev

How to get the name of the currently active sheet in Openpyxl

Related Related

  1. 1

    Get the name of the currently executing method in dotnet core

  2. 2

    Get the name of currently executing @Test method name in @BeforeMethod and @AfterMethod in testng

  3. 3

    Getting the name of the currently executing method

  4. 4

    Get the name of the currently executing testing test?

  5. 5

    Get name of currently executing test in JUnit 4

  6. 6

    Can you use reflection to find the name of the currently executing method?

  7. 7

    How do I get the path and name of the file that is currently executing?

  8. 8

    How to get the fully-qualified name of the currently executing function?

  9. 9

    How do I get the name of the Scenario step currently executing?

  10. 10

    How to get interface implementation type for currently executing method?

  11. 11

    How To Get Name of Calling Method and Executing Method of Lambda Expression

  12. 12

    Java : Getting the currently executing Method corresponding object

  13. 13

    Jenkins plugin - how to get currently executing job?

  14. 14

    Get name of currently logged in user

  15. 15

    Snowflake - how do I retrieve the name of the currently executing procedure?

  16. 16

    How to get the name of the executing type?

  17. 17

    Get the currently executing script element inside a type="module" script

  18. 18

    How to get the file-path of the currently executing javascript code

  19. 19

    How do I get the directory that the currently executing jar file is in?

  20. 20

    Get the path of the script that is currently executing in Steel Bank Common Lisp

  21. 21

    Get currently executing javascript line in react native javascript engine for debugging

  22. 22

    Use dbus to get name of mediaplayer currently playing

  23. 23

    How to get the name of the currently active window in Python?

  24. 24

    Get name of currently active thread in ThreadPoolExecutor android

  25. 25

    How to get name of currently loaded fxml file?

  26. 26

    Get the currently used protocol name from HttpServletRequest?

  27. 27

    Get the name of the state that is currently being transitioned to

  28. 28

    Get currently executed describe/test name

  29. 29

    How to get the name of the currently active sheet in Openpyxl

HotTag

Archive