Perhaps a singleton class? It seems to me that you're probably in need of
some more abstraction if you feel you need a global variable.
On May 27, 2012 8:34 AM, "Phil Stone" <lists / ruby-forum.com> wrote:

> Hello,
> Ever since I started learning Ruby, I've been strongly discouraged
> from using global variables
> (http://www.caliban.org/ruby/rubyguide.shtml#style)
> (http://www.ruby-forum.com/topic/187685#819233).
>
> In a program I'm making, I have a variable (which stores an instance of
> a class) that is declared outside of any functions or classes. However,
> I need to be able to call its methods from various class and function
> scopes, and nothing but a global variable would let me do that. This
> variable is simply what the program is centered around, and must be
> accessed and edited by various classes. I'm not sure why a global
> variable would be such a bad habit in this case, especially since it is
> only one.
>
> Can I justify using it?
>
> --
> Posted via http://www.ruby-forum.com/.
>
>