# Is there a method I can call where:

**URL:** <https://www.ruby-forum.com/t/is-there-a-method-i-can-call-where/190381>\
**Category:** Ruby\
**Created:** [June 18, 2010, 10:08pm UTC](https://www.ruby-forum.com/t/is-there-a-method-i-can-call-where/190381 "2010-06-18T22:08:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/u/Xeno_CSS_Eskimo_No)\
**Post date:** [June 18, 2010, 10:08pm UTC](https://www.ruby-forum.com/t/is-there-a-method-i-can-call-where/190381/1 "2010-06-18T22:08:08Z")

</div>

If I have:

class Blek  
def bM  
puts “trace #{self.somemethod}”  
end  
end

bo = Blek.new  
bo.bM

It will give me:

trace bo.bM  
or  
trace bM

???

I want to set up stuff that tells me what method I am in, largely for  
raising  
exceptions in various circumstances, but I want to control the message  
myself,  
so I’d like specifically knowledge of the method name available as  
stated.

---

<div class="post-metadata">

**Author:** ![Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/u/Xeno_CSS_Eskimo_No)\
**Post date:** [June 18, 2010, 10:32pm UTC](https://www.ruby-forum.com/t/is-there-a-method-i-can-call-where/190381/2 "2010-06-18T22:32:26Z")

</div>

Xeno C. / Eskimo North and Gmail wrote:

> so I’d like specifically knowledge of the method name available as  
> stated.

The **method** method should do the trick:

ruby -v: ruby 1.9.1p378 (2010-01-10 revision 26273) [x86\_64-linux]  
irb(main):001:0\> def foo  
irb(main):002:1\> p **method**  
irb(main):003:1\> end  
=\> nil  
irb(main):004:0\> foo  
:foo  
=\> :foo  
irb(main):005:0\>

That one is implemented since 1.8.7 I think. The class name is available  
via #class.

Marvin

---

<div class="post-metadata">

**Author:** ![Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/u/Xeno_CSS_Eskimo_No)\
**Post date:** [June 18, 2010, 10:33pm UTC](https://www.ruby-forum.com/t/is-there-a-method-i-can-call-where/190381/3 "2010-06-18T22:33:53Z")

</div>

**method** or **callee**

On Jun 18, 4:03 pm, Xeno C. / Eskimo North and Gmail

---

<div class="post-metadata">

**Author:** ![Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/u/Xeno_CSS_Eskimo_No)\
**Post date:** [June 18, 2010, 10:45pm UTC](https://www.ruby-forum.com/t/is-there-a-method-i-can-call-where/190381/4 "2010-06-18T22:45:36Z")

</div>

On 10-06-18 01:32 PM, Intransition wrote:

> **method** or **callee**

Thank you. **method** seems to work, but **callee** seems to fail, and  
I cannot  
find it in pickaxe:

> ./test.rb:8:in `bm': undefined local variable or method` **callee** ’ for #Blek:0xb78989f8 (NameError)  
> from ./test.rb:18

I tried several variations of that too, and they all fail. Still, you  
got me  
going. Thank you very much.

Sincerely, Xeno.  
xc

---

<div class="post-metadata">

**Author:** ![Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/a9a28c/32.png) [@Xeno\_CSS\_Eskimo\_No](https://www.ruby-forum.com/u/Xeno_CSS_Eskimo_No)\
**Post date:** [June 19, 2010, 12:22am UTC](https://www.ruby-forum.com/t/is-there-a-method-i-can-call-where/190381/5 "2010-06-19T00:22:47Z")

</div>

On Jun 18, 4:44 pm, Xeno C. / Eskimo North and Gmail  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 10-06-18 01:32 PM, Intransition wrote:
> 
> > **method** or **callee**
> 
> Thank you. **method** seems to work, but **callee** seems to fail, and I cannot  
> find it in pickaxe:
> 
> > ./test.rb:8:in `bm': undefined local variable or method ` **callee** ’ for #Blek:0xb78989f8 (NameError)  
> > from ./test.rb:18

It’s a 1.9. thing:

[eigenclass.org](http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l168)
