Hello,
How do I get the name of the method I'm in (perhaps with line-number) ?
(like the error-stack when failing)
thank you
Opti
Hello,
How do I get the name of the method I'm in (perhaps with line-number) ?
(like the error-stack when failing)
thank you
Opti
<https://ruby-doc.org/core-2.7.0/Kernel.html>
*[1] pry(main)> def mymethod[1] pry(main)* [ __method__,
self.method(__method__).source_location ][1] pry(main)* end=> :mymethod[2]
pry(main)> mymethod=> [:mymethod, ["(pry)", 5]][3] pry(main)>*
-gf-
On Sat, Aug 28, 2021 at 7:24 PM Die Optimisten <inform@die-optimisten.net> wrote:
Hello,
How do I get the name of the method I'm in (perhaps with line-number) ?
(like the error-stack when failing)thank you
Opti
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Hello,
is it possible to do this it only once (metaprogramming), so that it is
done for all (my) methods starting AND ending ?
- Do I have to build the method-call stack by myself, or can I somehow
use the avalilable call-stack?
thank you
Opti
--
-gf-
is it possible to do this
What is "this"?
On Sun, Aug 29, 2021 at 5:25 PM Die Optimisten <inform@die-optimisten.net> wrote:
It sounds like your intention is to trace and log program execution ? ...
You may find this useful:
-gf-
On Sun, Aug 29, 2021 at 11:25 AM Die Optimisten <inform@die-optimisten.net> wrote:
Hello,
is it possible to do this it only once (metaprogramming), so that it is
done for all (my) methods starting AND ending ?- Do I have to build the method-call stack by myself, or can I somehow
use the avalilable call-stack?thank you
Opti
--
-gf-
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
You most probably think about one of these methods:
https://rubyapi.org/3.0/o/kernel#method-i-caller
https://rubyapi.org/3.0/o/kernel#method-i-caller_locations
The first one returns Strings, the second one a Thread::Backtrace::Location which respond to methods like #lineno and #label which can help you achieve what I think you try to achieve.
On 8/29/21 1:23 AM, Die Optimisten wrote:
Hello,
How do I get the name of the method I'm in (perhaps with line-number) ?
(like the error-stack when failing)thank you
Opti
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>