Now my code works as such:
def method_a self.method_b ==> 'method_b' end def method_b puts self.name_of_calling_method end def name_of_calling_method if /`(.*)'/.match(caller.first) return $1 else return nil end end
Instead of the method_b method for printing 'method_b', how can I print the name of the calling method - 'method_a'?
Replace caller.firstwith caller[1].
caller.first
caller[1]
When you are in name_of_calling_methodcalled from method_b, then method_athis is 1 record above the call stack, so you want caller[1]to name_of_calling_method, not caller.firstor caller[0].
name_of_calling_method
method_b
method_a
caller[0]
caller , nil , method_b caller[1] nil - else .
caller
nil
else
Source: https://habr.com/ru/post/1740208/More articles:How to get regex length in vim? - vimajaxify multipart encoded form (download forms) - javascriptLINQ: converting an array [,] to an array [] - c #SQL Server - поиск строки с международными символами с использованием предложения LIKE - sqlclosing does not work - javascriptИспользование FindAll в списке> type - listC ++ library for implementing api web services using legacy code? - c ++Import a small number of records from a very large CSV file into Biztalk 2006 - flat-filehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1740212/stacking-last-and-checked-jquery-selectors-together&usg=ALkJrhhyDyIjdpmGawVcHn9VsMsocedaAAHow to handle click click event in jQuery grid - jqueryAll Articles