같은 작동합니다호출 메소드의 문자열 이름을 반환하는 방법은 무엇입니까? 지금 내 코드
대신 method_b 인쇄 'method_b'의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
는 어떻게 호출하는 메소드의 이름을 인쇄 할 수 있습니다 - 'method_a'를?