If condition based on method calling

Say I have a three methods

def method1

method3
end

def method2

method3
end

def method3
end

Can I write an if condition in method3 based on which method called
method3

so I in short I am asking how do I write the below pusedo code in
method3

if method1
…do something
else
if method2
…do something

Look into the ‘caller’ method
(http://corelib.rubyonrails.org/classes/Kernel.html#M002048).

def method3
from = (caller[0].match(/in `(.*?)'/) || [])[1]
puts “called from #{from}”
end


-yossef