I’m new to Ruby.
I hear modules can be used similar to namespaces.
I want to place a variable (value does vary so not a constant) inside a “namespace” and have it accessible from outside.
Searching, I find there’s a few different ways.
cattr_accessor - I can’t yet figure out how to install or use this properly and I’m not using rails. (require fails with “cannot load such file – facets/module/cattr” although facets is installed and just “facets” loads).
getters and setters. These require far too much code to set up, and the setter examples I see seem to only set the = operator, so I can’t use += etc.
What is the least verbose way to let me do something like
module Foo @@x = 5; end Foo.x = 6; puts Foo.x; # 6
It doesn’t have to use module, I just want namespacing.