From: William Djaja Tjokroaminata Date: 2002-04-12T23:57:50+09:00 Subject: Re: How to Make a Method Ineffective Efficiently? Thanks for the suggestion. I think it is a pretty good idea when I am actually dealing with debugging. However, what I am dealing with is more like tracing: class Trace attr_accessor :active attr_reader :name def initialize (name, active) end def write if @active .... (heavy processing) end end end @tr1 = Trace.new ('ATM Data Flow', true) @tr2 = Trace.new ('Routing Information', true) @tr3 = Trace.new ('TCP Timeout', false) .... @tr1.write (obj1, obj2, ob3) @tr2.write (obj1) @tr3.write (obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8) Therefore, these are the problems: 1) I cannot define just a single global variable such as $DEBUG 2) I cannot define the method with no argument 3) When I define the method with variable number of arguments, I think the objects will still be passed in the array even though the method actually does nothing. 4) Doing preprocessing on the code will not work, because the state can only be inferred within the code execution, as dictated by the member data "@active". Regards, Bill ========================================================================== Nikodemus Siivola wrote: > How about: > if $DEBUG > require 'debug' > else > require 'no_debug' > end > and in file "debug.rb" you would define you debug method(s), making them as > heavy as you pleae, and in file "no_debug.rb" you would just define empty > methods like: > def debug; end > Alternatively: > Comment out your debug code like this for exaple: > #DEBUG debug( var1, var2, var3 ) > and then you can generate the debugging version of your source by: > ruby -pe "$_.gsub( /(^\s+)#DEBUG/, '\1' ) debug.rb > -- Nikodemus