From: Stefano Crocco Date: 2009-11-24T20:03:13+09:00 Subject: Re: Warning: instance variable @foo not initialized On Tuesday 24 November 2009, Seebs wrote: > |On 2009-11-24, Stefano Crocco wrote: > |> If the warnings only annoy you, you should be able to disable them by > |> not passing the -w option to ruby. If instead you're worried that they > |> can mean there's something wrong, I think you don't need to. Most of the > |> times, warnings issued by ruby are harmless. > | > |There's two issues. > | > |1. Actually, those warnings happen even without -w. (Unless there's > |something non-obvious passing the -w to Ruby that I didn't think about.) > |2. I actually really DO want -w warnings for my code. Is there a way to > |do a require that suppresses warnings during parsing of the required code? > | > |-s > | I never used Prawn, so I can't tell why it issues warnings even without the -w option. However, you can control this setting from inside your code using the $VERBOSE global variable. It is initially set by ruby to one of the following values: * true if the -w, -v or --verbose flags have been passed on the command line * nil if the -W0 flag has been passed on the command line * false if none of the above flags has been given You can change it from inside your code to avoid warnings from Prawn: #your code ... old_verbose = $VERBOSE $VERBOSE = nil #code which makes prawn issue warnings ... $VERBOSE = old_verbose Stefano