Logger를 쓰고 있는데 print_log 메소드를 호출 한 클래스 이름을 자동으로 추가하는 데 문제가 있습니다. 이 같은 예를 들어 뭔가 :호출자 클래스 가져 오기
I 출력에보고 싶어MyClass.new
메소드를 호출의 결과
class Logger
def self.print_log(string)
puts Time.now.strftime('%T | ') + *caller_class_name_here* + ' - ' + string
end
end
class MyClass
def initialize
Logger.print_log 'called .new() method'
end
end
:
14시 41분 23초 | MyClass에 - .new를 호출() 메소드
나는 클래스 이름 등을 얻을 수있는 경우
http://stackoverflow.com/questions/4116525/sender-class-in-r 여기서 가능한 uby는 대답입니다 ... ( – Hroft